Below is the code for Files I/O operations in Python
import os
import sys
sys.path.extend(r'mention your local path here')
print('Get current working directory : ', os.getcwd())
print('File name : ', os.path.basename(__file__))
print('Directory Name: ', os.path.dirname(__file__))
print('Absolute path of file: ', os.path.abspath(__file__))
print('Absolute directory name: ', os.path.dirname(os.path.abspath(__file__)))
# Specify the directory you want to list
directory_path = os.getcwd()
# List all files and folders in the directory
file_list = os.listdir(directory_path)
# Get full paths
full_paths = [os.path.join(directory_path, file) for file in file_list]
print(full_paths)
Comments
Post a Comment