【python】获取当前时间(年月日时分秒)

需要用到 time 包,这个包python自带,无需另外下载。

想要哪个,就在字符串里输入哪个就行了,它会自动匹配的。

import time    

print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))) # 显示年-月-日-时-分-秒
print(time.strftime('%Y-%m-%d %H:%M',time.localtime(time.time()))) # 显示年-月-日-时-分
print(time.strftime('%Y-%m-%d',time.localtime(time.time())))  # 显示年-月-日

【python】获取当前时间(年月日时分秒)_第1张图片

你可能感兴趣的:(pytorch,python,开发语言)