Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Pythonファイルオブジェクト現在のシード位置からバイトを削除して終了する方法
f = open(filename, "a+")
truncate_pos = f.tell()
f.truncate(truncate_pos)
うまくいかないようですが、どうすればよいですか?
ファイルを開くとa+、ポインタがファイルの最後に配置されます。そこから切り捨てても、ファイルは変更されません。
a+