获取当前工作目录
import os
import sys
# 方法1
cwd = os.getcwd()
# 方法2
cwd = os.path.dirname(os.path.realpath(__file__))
# 方法3
cwd = os.path.dirname(os.path.abspath(__file__))
# 方法4
cwd = sys.path[0]
获取当前执行脚本的位置
import sys
file = sys.argv[0]
import os
import sys
# 方法1
cwd = os.getcwd()
# 方法2
cwd = os.path.dirname(os.path.realpath(__file__))
# 方法3
cwd = os.path.dirname(os.path.abspath(__file__))
# 方法4
cwd = sys.path[0]
import sys
file = sys.argv[0]