본문 바로가기
지속가능티끌/Python

Python. time . sleep . datetime. 밀리초 등

by i.got.it 2019. 5. 22.

 

 

 

time.sleep(secs)

- 인자 : 초단위 시간, 실수, 정수 모두 가능 

 

from time import sleep 
sleep(3)
sleep(0.1)
sleep(0.001)

 

 

 

time 상세정보. 

 

https://docs.python.org/3/library/time.html

 

time — Time access and conversions — Python 3.7.3 documentation

time — Time access and conversions This module provides various time-related functions. For related functionality, see also the datetime and calendar modules. Although this module is always available, not all functions are available on all platforms. Most

docs.python.org

 

 

 

마이크로초, 밀리초 , 초 단위 정수로 시간 받기 

 

import datetime

#timestamp() 형식 : 1631069486.025195 즉 초이하는 소수점 이하 6자리까지 표현.
def get_time_us(): # 마이크로 초 단위로 시간 정수로 받기.형식 1631069486025195 
    return round(datetime.datetime.utcnow().timestamp() * 1000000) # 형식 

def get_time_ms(): # 밀리초 단위로 시간 정수로 받기. 
    return round(datetime.datetime.utcnow().timestamp() * 1000)

def get_time_sec(): # 초 단위로 시간 정수로 받기. 
    return round(datetime.datetime.utcnow().timestamp())

 

 

 

 


첫등록 : 2019년 5월 22일 

최종수정 : 2021.09.08

 

본 글 단축주소 : https://igotit.tistory.com/2190

 


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5