import os
import time
basedir = os.path.abspath(os.path.dirname(__file__))
print(basedir)
t1 = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
print(t1)
with open(basedir+"/"+"1.txt","a",encoding = "utf-8") as f:
f.write(t1+":"+"hello")
f.write("\r\n")
f.close()
Python 小练习-4 获取当前文件的路径和当前时间
最新推荐文章于 2022-07-21 00:10:26 发布