Voglio ottenere il percorso della directory corrente in cui viene eseguito un file .py.
Ad esempio un semplice file D:\test.pycon codice:
import os
print os.getcwd()
print os.path.basename(__file__)
print os.path.abspath(__file__)
print os.path.dirname(__file__)
È strano che l'output sia:
D:\
test.py
D:\test.py
EMPTY
Mi aspetto gli stessi risultati da getcwd()e path.dirname().
Dato os.path.abspath = os.path.dirname + os.path.basename, perché
os.path.dirname(__file__)
ritorna vuoto?