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
'지속가능티끌 > Python' 카테고리의 다른 글
파이썬. 웹소켓. WbeSocket 구현. (0) | 2020.03.11 |
---|---|
Python. 소켓통신 (0) | 2019.10.28 |
Pyhton. print. 실수 자리수 제한등 (0) | 2019.05.19 |
Python. ctypes. structure. 구조체 (0) | 2019.05.16 |
Python. if . 비교연산자, and, or not, in, not in , (0) | 2019.05.16 |
댓글0