How to get full path to python program including filename within the program?
问题 I have a python program, and I want to get the path to the program from within the program, but INCLUDING the file name itself. The name of my file is PyWrapper.py. Right now I'm doing this: import sys,os pathname = os.path.dirname(sys.argv[0]) fullpath = os.path.abspath(pathname) print fullpath The output is: /home/mrpickles/Desktop/HANSTUFF/securesdk/src/ This is the path to the directory in which my file is saved, but I would like it to output: /home/mrpickles/Desktop/HANSTUFF/securesk/src