get a file insinde a folder python code example
Example 1: python list files in current directory
import os
files = os.listdir('.')
print(files)
for file in files:
# do something
Example 2: get list of files in directory python
import os
path = '/folder1/folder2/'
files = os.listdir(path)
Example 3: open file in python directory
path = 'C:\\Users\\Username\\Path\\To\\File'
file=open(path, "r")