我有一个文字文件namefile.txt,有更多的性格.我想删除所有文本并保留文件,以便namefile.txt在运行python脚本后打开时看到nothings ?
这样做.从概念上打开具有写入权限的文件会清除以前的数据.
open('namefile.txt', 'w').close()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
762 次 |
| 最近记录: |