Under py3, __file__
it returns the file absolute address ;
and in py2, __file__
the return of the file relative address .
Want to get the files in the py2 absolute address, you can help os.path.abspath()
:
import os
print(os.path.abspath(__file__))
You can get absolute address.