(데이터 분석)파이썬- datetime

    728x90
    import cx_Oracle as cx
    
    # ----------------------- 예시 -----------------
    
    # from pkg.lec08_class import UserClass
    
    # u1 = UserClass('kim', 64)
    
    # u1.userInfo(22)          # 주소u1 = 인스턴스함수
    
    # UserClass.userPrint('아무개')      # 클래스함수
    
    # # --------------------------------------------
    
    
    # from datetime.py import datetime.class
    
    # from datetime.py import date.class
    
    # from datetime.py import datetime.class, date.class
    
    from datetime import datetime, date
    
    aa = date(year=2020, month=4, day=10)
    
    aa = date(2020, 4, 10)
    
    print(aa, type(aa))
    
    # bb = datetime().strptime('2020/07/18', '%Y/%m/%d')
    
    bb = datetime(year=2020, month=1, day=7, hour=0, minute=0, second=0)
    
    bb = datetime(2020, 1, 7, 1, 20, 33)
    
    print(bb, type(bb))
    
    #---------------------아래것만 wkf써도 성공 --------------------
    from datetime import datetime, date
    
    aa = date(2020, 10, 1)
    
    bb = datetime(2020, 10, 1)
    
    cc = '2020-10-01'
    #datetime.strptime(date_string='2020-01-01', format='%Y-%m-%d')
    xx=datetime.strptime('2020-01-01','%Y-%m-%d')
    zz=date.fromisoformat('2020-07-18') #시간 표시 X
    #---------------------------------------------------------------
    print(type(aa), type(bb), type(cc))
    
    print(aa, bb, cc,xx,zz)

    datetime 패키지는 파이썬으로 데이터 입력할 시, 날짜형식으로 저장하기 위해 활용된다.

    댓글