プログラム言語 Pythonのos.path.getsize()はファイルのサイズを取得するために有用ですが、
私の場合は下記の様にwith openで対象ファイルをオープンしている中でos.path.getsize()を使っていたためにファイルサイズが0と表示されてしまっていました。
例:
with open("tmp.txt", "w", encoding='cp932') as f:
print(os.path.getsize("tmp.txt"))
そのためwith openの範囲外でos.path.getsize()を行なえば正しくファイルサイズを得られました。
(コメントされる場合はコメントの最初にjjjjと入れて下さい。無い場合はスパムとみなされてしまいます。 English comments will be welcomed. If you have any comments, please write 'jjjj' at first of your comments OR spam filters will delete your comments.)
スポンサードリンク