在python中:
open('file.txt', 'w').close()
或者,如果你已经打开了一个文件:
f = open('file.txt', 'r+')
f.truncate(0) # need '0' when using r+
在python中:
open('file.txt', 'w').close()
或者,如果你已经打开了一个文件:
f = open('file.txt', 'r+')
f.truncate(0) # need '0' when using r+
相关文章: