Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to see directory from os module

import os

# detect the current working directory
path = os.getcwd()

# read the entries
with os.scandir(path) as listOfEntries:
    for entry in listOfEntries:
        # print all entries that are files
        if entry.is_file():
            print(entry.name)
Comment

how to see directory from os module

#! /bin/bash

for filename in *.py; do
    echo "$filename:"
    cat $filename | python3 -m timeit
    echo " "
done
Comment

how to see directory from os module

import pathlib

# define the path
currentDirectory = pathlib.Path('.')

# define the pattern
currentPattern = "*.py"

for currentFile in currentDirectory.glob(currentPattern):
    print(currentFile)
Comment

how to see directory from os module


import pathlib

# define the path
currentDirectory = pathlib.Path('.')

for currentFile in currentDirectory.iterdir():
    print(currentFile)
Comment

PREVIOUS NEXT
Code Example
Python :: Use a callable instead, e.g., use `dict` instead of `{}` 
Python :: hide turtle 
Python :: Drop multiple columns with their index 
Python :: discord.py get user id 
Python :: change markersize in legend matplotlib 
Python :: identity matrix python 
Python :: Aggregate on the entire DataFrame without group 
Python :: pafy doc 
Python :: How to filter with Regex in Django ORM 
Python :: list of dict to dict python 
Python :: python unittest coverage main function 
Python :: Normalize columns in pandas dataframe 
Python :: interface, abstract python? 
Python :: how to make a timer using python 
Python :: filter directory in python 
Python :: remove whitespace from data frame 
Python :: matplotlib: use colormaps for line plot colors 
Python :: python divide array into n parts 
Python :: dataframe look at every second column 
Python :: web scraping using python code 
Python :: factorial program in python 
Python :: calculate the shortest path of a graph in python 
Python :: python logical operators 
Python :: pandas make dataframe from few colums 
Python :: django changing boolean field from view 
Python :: blur an image in python 
Python :: python find if string contains space 
Python :: django form field add attrs 
Python :: pop element from heap python 
Python :: Python Tkinter Scale Widget 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =