python 读写

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)

 

posted @ 2019-10-06 10:27  bloglxc  阅读(105)  评论(0编辑  收藏  举报