解决NameError: name '__file__' is not defined的方法 其他 2021-03-03 21:52 0 阅读 解决NameError: name ‘file’ is not defined的方法 在学习通过python处理yaml文件的时候,出现该问题。 方法1 import os base_dir = os.path.dirname(os.path.realpath('__file__')) print(base_dir) 方法2 import os base_dir = os.getcwd() print(base_dir) 猜你喜欢