update
Some checks failed
It_School_001/pipeline/head Something is wrong with the build of this commit
Some checks failed
It_School_001/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
27
Python_module_2/python_001.py
Normal file
27
Python_module_2/python_001.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def gestioneaza_fiesere(director):
|
||||
# Verificam daca directorul exista
|
||||
if os.path.exists(director):
|
||||
print(f"Directorul '{director}' exista. Fisierele din acest director sunt:")
|
||||
# Listam fisierele din director
|
||||
for nume_fisier in os.listdir(director):
|
||||
cale_fisier = os.path.join(director, nume_fisier)
|
||||
if os.path.isfile(cale_fisier):
|
||||
dimensiune_kb = os.path.getsize(cale_fisier) / 1024
|
||||
print(f"- {nume_fisier} ({dimensiune_kb:.2f} KB)")
|
||||
else:
|
||||
print(f"Directorul '{nume_fisier}' nu este un fisier.")
|
||||
else:
|
||||
os.mkdir(director)
|
||||
print(f"Directorul '{director}' nu exista. A fost creat.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
director_de_gestionat = sys.argv[1]
|
||||
gestioneaza_fiesere(director_de_gestionat)
|
||||
else:
|
||||
print("Va rugam sa specficati un director ca argument la linia de comanda.")
|
||||
Reference in New Issue
Block a user