I have two file in directory abc
test.py
hello.txt
File test.py
:
import os.path
if os.path.exists('hello.txt'):
print('yes')
else:
print('no')
when execute test.py in same directory, the output is, as I'd expect, 'yes'
abc > python test.py
output: yes
but when try to execute form other directory
~ > python ~/Desktop/abc/test.py
output: no
how to correct this
# the real case
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
it works when executing within directory abc
but fails form outside.