Answer the question
In order to leave comments, you need to log in
How to get Linux (Ubuntu) working category?
Question: I made python code on windows, worked with the os library, as soon as I put the script on a server running ubuntu, it os.path.abspath(os.getcwd())
started giving out not the full path like /home/papka/file , but just /file . How to get the full path to the folder in which the script is running?
Answer the question
In order to leave comments, you need to log in
os.getcwd() -- this is the path to the place from which the command to run the script was given,
which may not be the same as the path to the script
, I usually use os.path.dirname(__file__) -- it hasn't let me down in any os yet
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question