创建一个文件,写入当前日期
import datetime now = datetime.datetime.now() with open('c.txt','w') as f f.write(str(now))
1 with open('c.txt','r') as f: 2 text_4=f.read(4) 3 print(text_4)