我正在尝试使用以下方法将脚本的路径存储到变量中:
os.path.abspath(os.path.dirname(__file__))
Run Code Online (Sandbox Code Playgroud)
但是,它不断返回name '__file__' is not defined错误。
here = os.path.dirname(os.path.abspath(__file__))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '__file__' is not defined
Run Code Online (Sandbox Code Playgroud)