os.path.abspath(file) 作用: 获取当前脚本的完整路径
import os
print(os.path.abspath(__file__))
cur_path = os.path.dirname(os.path.abspath(__file__))
print(cur_path)
注:只有当在脚本中执行的时候,os.path.abspath(file)才会起作用,因为该命令是获取的当前执行脚本的完整路径,如果在交互模式或者terminate 终端中运行会报没有__file__这个错误