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  阅读(186)  评论(0编辑  收藏  举报