Answers for "add dir to path python"

0

add dir to path python

import sys
sys.path.insert(0,'/path/to/mod_directory')
Posted by: Guest on August-26-2021
-1

how to add directory to python script

import os

# List all files in a directory using scandir()
basepath = 'my_directory/'
with os.scandir(basepath) as entries:
    for entry in entries:
        if entry.is_file():
            print(entry.name)
Posted by: Guest on June-17-2020
-1

how to add directory to python script

from pathlib import Path

basepath = Path('my_directory/')
files_in_basepath = basepath.iterdir()
for item in files_in_basepath:
    if item.is_file():
        print(item.name)
Posted by: Guest on June-17-2020

Python Answers by Framework

Browse Popular Code Answers by Language