Skip to content

fernan281/GitHub-PJ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

import os

Get the current working directory

cwd = os.getcwd()

Initialize an empty list to store the file information

file_list = []

Iterate over the files in the current working directory

for filename in os.listdir(cwd): file_path = os.path.join(cwd, filename)

# Check if the file is a regular file (not a directory)
if os.path.isfile(file_path):
    # Get the size of the file in bytes
    file_size = os.path.getsize(file_path)
    
    # Create a dictionary to store the file information
    file_info = {
        "path": filename,
        "size": file_size
    }         
    # Add the file information to the list
    file_list.append(file_info)

Print the list of dictionaries

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages