random
from random import *
i = randint(1, 100)
print(i)
f = random()
print(f)
f = uniform(1.0, 36.5)
print(f)
i = randrange(1, 101, 2)
print(i)
i = randrange(10)
print(i)
time
import time
time.time()
import time
print(time.time())
1639146876.1980789
time.localtime(time.time())
import time
print(time.localtime(time.time()))
time.struct_time(tm_year=2021, tm_mon=12, tm_mday=10, tm_hour=23, tm_min=36, tm_sec=15, tm_wday=4, tm_yday=344, tm_isdst=0)
time.ctime()
import time
print(time.ctime())
Fri Dec 10 23:37:48 2021
time.strftime()
argument | description |
---|
%Y | 2021 (년) |
%m | 12 (월) |
%d | 10 (일) |
%H | 23 (시) |
%M | 39 (분) |
%S | 12 (초) |
import time
print(time.strftime('%Y-%m-%d %H:%M:%S'))
2021-12-10 23:39:12
time.sleep(1)
time.sleep()
: sec 단위로 프로세스를 block 시킴