python files | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

python files

I have file called deposit in Mac book pro. I want to open in read mode using its full location but it didn't work for me: deposit is in icloudrive/desktop/deposit.txt

27th Feb 2018, 9:52 PM
KHALIFA EL HARA
KHALIFA EL HARA - avatar
2 Answers
+ 10
import os dir = os.path.dirname(__file__) rel_path ="deposit" abs_file = os.path.join(dir, rel_path) where __file__ full path to directory with file
27th Feb 2018, 10:02 PM
__Nick
__Nick - avatar
+ 3
Thank you :)
27th Feb 2018, 10:03 PM
KHALIFA EL HARA
KHALIFA EL HARA - avatar