python获取当前项目所在文件路径(name ‘__file__‘ is not defined)

s.path.abspath(os.path.dirname(os.path.realpath(‘file’)))
注意__file__要加引号。否则会报错name ‘file’ is not defined

猜你喜欢

转载自blog.csdn.net/spatial_coder/article/details/123155923