Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- #get files in path
- PATH = "C:\\YourFolder\\"
- files = [f for f in os.listdir(PATH) if os.path.isfile(os.path.join(PATH, f))]
- print(files) #Outputs list of files in PATH
- #get extension of any file
- file = 'example.php'
- ext = os.path.splitext(file)[0]
- print(ext) #Outputs php
Advertisement
Add Comment
Please, Sign In to add comment