您的位置: 首页 > IT文章 > python 读写 python 读写 分类: IT文章 • 2022-08-27 11:16:26 1、读 1 f = read('$filePath', 'r') 2 line = f.readline() #读取一行 3 lines = f.readlines() #读取所有行 2、写 1 with open('$filePath', 'w') as fw: 2 fw.write(sth)