time
import time
a = time.time()
b = time.ctime()
c = time.strftime("%b %d %Y %H:%M:%S")
print(a)
print(b)
print(c)
执行结果
1566743022.071017
Sun Aug 25 22:23:42 2019
Aug 25 2019 22:23:42
IO
open读文件
第一种(需要close)
# 文件读取
f_read = open('1.txt')
fp = f_read.read()
print(fp)
f_read.close()
# 文件写入
f_wri = open("1.txt","a")
f_wri.write("hello world")
f_wri.close()
第二种(不需要关闭)
with open("1.txt",'r') as fp:
a = fp.read()
print(a)
网友评论