最佳答案
在 Unix shell 中,我可以这样清空一个文件:
cd /the/file/directory/
:> thefile.ext
我该如何在 Python 中实现这一点呢?
是 os.system的方式在这里,我不知道如何,因为我将不得不发送两个动作后,即 cd,然后 :>。