Answers for "find python folder"

15

which folder python os

import os
cwd = os.getcwd()
Posted by: Guest on March-09-2020
3

get python directiory

import sys
print('n'.join(sys.path))
Posted by: Guest on May-09-2020
7

how to find where python is located

>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\Python25'
Posted by: Guest on May-28-2020
0

find directory in directory python

import os

def listdir_r(dirpath):
  	"""lists directories and sub-directories recursively. 
    """
    paths=[]
    paths.append(dirpath)
    for path in os.listdir(dirpath):
        rpath = os.path.join(dirpath, path)
        if os.path.isdir(rpath):
            subdirs = listdir_r(rpath)
            if not subdirs == []:
                paths.extend(subdirs)
    return paths

# print the list of sub-directories
print(listdir_r('./'))
Posted by: Guest on June-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language