Skip to content

Instantly share code, notes, and snippets.

@hwpplayer1
Created February 3, 2026 08:59
Show Gist options
  • Select an option

  • Save hwpplayer1/11fb22a310d6d885874d1b17e18f105a to your computer and use it in GitHub Desktop.

Select an option

Save hwpplayer1/11fb22a310d6d885874d1b17e18f105a to your computer and use it in GitHub Desktop.
list.py
import os
def list_files(path):
try:
files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
print(f"'{path}' içindeki dosyalar:")
for f in files:
print(f)
except Exception as e:
print(f"Hata: {e}")
def list_directories(path):
try:
dirs = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]
print(f"'{path}' içindeki klasörler:")
for d in dirs:
print(d)
except Exception as e:
print(f"Hata: {e}")
# Kullanıcıdan yol al
directory_path = input("Listelemek istediğin klasör yolunu gir: ")
list_files(directory_path)
list_directories(directory_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment