Answers for "python get path of script"

9

get path to current directory python

import os
os.path.abspath(os.getcwd())
Posted by: Guest on September-16-2020
1

get python script path

import os
def GetScriptPath():
    return os.path.realpath(__file__);

print(GetScriptPath());
Posted by: Guest on June-11-2021
2

python get directory path of script

import os

# To get absolute path to current script
absolutePath = os.path.realpath(__file__)
print(absoultePath) # c:\File\Path\to\Current\Script.py

# To get absolute path excluding file name
directory = ("//".join(os.path.realpath(__file__).split('//')[:-1]))
print(directory) 	# c:\File\Path\to\Current	  split('\\') for windows
Posted by: Guest on June-21-2021
2

python get script path

os.getcwd()
Posted by: Guest on June-03-2020
-3

get pyhton file path python

import os

os.path.realpath(__file__)
Posted by: Guest on October-13-2020
-4

get path from file path python

>>> import os
>>> os.path.split(os.path.abspath(existGDBPath))
('T:\\Data\\DBDesign', 'DBDesign_93_v141b.mdb')
Posted by: Guest on February-13-2021

Code answers related to "python get path of script"

Python Answers by Framework

Browse Popular Code Answers by Language