if문
~~ 조건을 만족한다 ==> True + 그러면 물건을 살수있다.
~~ 조건을 만족하지 못한다 ==> False + 그러면 물건을 사지 못한다.
if 조건문:
print("~~~")
else:
print("~~~")
(매우 간단한 내용이라 넘어감)
날짜/시간 활용하기
datetime(파이썬 기본 라이브러리)
+ https://docs.python.org/3/library/datetime.html
datetime — Basic date and time types
Source code: Lib/datetime.py The datetime module supplies classes for manipulating dates and times. While date and time arithmetic is supported, the focus of the implementation is on efficient attr...
docs.python.org
pandas to_datetime:
https://pandas.pydata.org/docs/reference/api/pandas.to_datetime.html
datetime 라이브러리 사용하기
현재 날짜/시간 구하기
여기서 년, 월, 일만 빼서 쓰고 싶다면
for 반복문
Python에서 for문을 쓰는것은 C언어와 Java와는 조금 다르게 생겼습니다.
for i in range(반복횟수):
print("출력")
이라고 하면 반복횟수를 적은만큼 출력이 나옵니다. 예를들어 3을 적었다면 출력이 3개가 나옵니다.
그리고 튜플이나 배열을 만들어서도 가능합니다.
하지만, 반복할 대상이 Sequence 자료형이 아니라 Scalar 자료형이라면
이렇게 iterable 하지않다고 (반복적으로 이어져있지않은) 반복문이 실행이 되지 않습니다.
결론적으로 Python에서 for문을 실행시키려면 Sequence 자료형이여야 가능합니다.
'한국경제신문(toss bank)' 카테고리의 다른 글
Docstring (함수 문서화) (0) | 2024.06.28 |
---|---|
Python while(반복문) 함수(def) (0) | 2024.06.28 |
Python list method, dictionary (0) | 2024.06.27 |
python 가상환경, source venv/Scripts/activate (0) | 2024.06.26 |
2024-06-26 교육 2일차 git, python 환경설정 (0) | 2024.06.25 |