일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- clustering
- 코랩 런타임
- NLP
- 알고리즘
- Selenium
- kmeans
- 웹페이지
- Chat-GPT
- colab runtime
- 셀레니움
- string to list
- Merge Repositories
- python buildpacks
- 괄호 문제
- geopandas
- convert to shp
- flask
- 크롤링
- geoDataFrame
- 파이썬
- Python
- to shp
- 플라스크
- 혁신성장부문
- 백준
- Crawling
- 해시태그
- plotly dash
- 인스타그램
- 2164 카드2
- Today
- Total
목록파이썬/문법 (12)
코딩코딩코딩
import matplotlib.pyplot as plt from matplotlib import rc rc('font', family='AppleGothic') plt.rcParams['axes.unicode_minus'] = False
import warnings warnings.filterwarnings(actions='ignore')

import seaborn as sns import matplotlib.pyplot as plt from matplotlib import rc rc('font', family='AppleGothic') plt.rcParams['axes.unicode_minus'] = False
x = 2021.09.11 00:02 y = 2021.09.11 00:00 type(x) >>> str datetime 형식으로 되어있지만 문자열인 경우 from datetime import datetime converted_x = datetime.strptime(x, "%Y.%m.%d %H:%M") converted_y = datetime.strptime(y, "%Y.%m.%d %H:%M") converted_x >>> 2021-09-11 00:02:00 형태로 변환됨. xy = converted_x - converted_y xy >>> Timedelta('0 days 00:02:00') xy.seconds >>> 120 Timedelta의 seconds를 구한 후에 몫, 나머지 혹은 나누기 연산자를 ..
sys의 readline 메서드를 사용하다보면 개행문자가 끝에 포함되어 있는데 이 문자를 처리하기 위해 strip()을 사용하면 됨 str.strip()은 문자열 양쪽 끝의 특정 문자를 제거해주는 역할을 함 input = sys.stdin.readline() a = list(input) print(f"a-> {a}") b = input.strip() print(f"b-> {b}") c = input.strip('\n') print(f"c-> {c}") >>> >>> XYZ a-> ['X', 'Y', 'Z', '\n'] b-> XYZ c-> XYZ b의 경우처럼 인자가 생략되어 없는 경우 기본문자인 공백을 제거함 c처럼 명시적으로 인자를 표시해줄 수도 있음
AST: Abstract Syntax Trees module (문법을 구조화 시켜주는 모듈) import ast str_dict = "{'key_1': 'value_1', 'key_2': 'value_2'}" # str_dict는 딕셔너리 형태를 가진 문자열임 real_dict = ast.literal_eval(str_dict) # real_dict는 딕셔너리 형태로 변환되었기 때문에 key-value를 사용할 수 있음