Contoh program : Program Python untuk Memeriksa Ukuran File

0
(0)

Contoh 1: Menggunakan modul os

import os

file_stat = os.stat('my_file.txt')
print(file_stat.st_size)

Keluaran

34

Satuan ukuran file adalah byte.


Contoh 2: Menggunakan modul pathlib

from pathlib import Path

file = Path('my_file.txt')
print(file.stat().st_size)

Keluaran

34

Satuan ukuran file adalah byte.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.


Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/breatgem/widiyanata.com/wp-includes/functions.php on line 4755