study 第三方库


import
os print(os.listdir()) #列出当前目录下的文件 print(os.getcwd()) #获取绝对路径 if not os.path.exists("b"): os.mkdir("b") if not os.path.exists("b/test.ext"): f = open("b/text.txt","w") f.write("hello,feifei") #写入 f.close()

 

 

 

time

import time

#打印当前时间
print(time.time())
print(time.localtime())
print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()))  #格式化

#打印两天前的时间
now_timestamp = time.time()
two_days_ago = now_timestamp - 2*24*60*60
time_tuple = time.localtime(two_days_ago)
print(time.strftime("%Y-%m-%d %H:%M:%S",time_tuple))

 

import math

print(math.ceil(5.4))  #大于等于的整数
print(math.floor(5.5)) #小于等于的整数

 

posted @ 2021-12-08 14:42  feifei_tian  阅读(34)  评论(0编辑  收藏  举报