python with open读写文件

with open( '/path/to/file', 'r' ) as f:
    print( f.read() ) 

with open('/Users/michael/test.txt', 'w') as f:
    f.write('Hello, world!')

 

posted @ 2022-05-19 12:30  豆浆D  阅读(208)  评论(0)    收藏  举报