python - file(write operation)

 

创建文件,并写入数据:

 

 

 

 

 

append 数据

 

 

 

 

 

 

Passing ‘w’ to the open() method tells Python to open the file in write mode. In this mode, any data already in the file is lost when the new data is written.

If the file doesn’t exist, Python will create a new file. In this case, a new file named “sample.txt” will be created when the program runs.

 

 

 

posted @ 2021-10-08 13:47  xman888  阅读(27)  评论(0编辑  收藏  举报