在python中:
open('file.txt', 'w').close()或者,如果您已经打开了文件:
f = open('file.txt', 'r+')f.truncate(0) # need '0' when using r+在C ++中,您可以使用类似的东西。

在python中:
open('file.txt', 'w').close()或者,如果您已经打开了文件:
f = open('file.txt', 'r+')f.truncate(0) # need '0' when using r+在C ++中,您可以使用类似的东西。