方法一
獲取當前py文件的絕對路徑
import re
dirname, filename = os.path.split(os.path.abspath(__file__))
方法二
獲取程序入口的絕對路徑
import os
import sys
dirname, filename = os.path.split(os.path.abspath(sys.argv[0]))
os.path.realpath(sys.argv[0])
獲取當前py文件的絕對路徑
import re
dirname, filename = os.path.split(os.path.abspath(__file__))
獲取程序入口的絕對路徑
import os
import sys
dirname, filename = os.path.split(os.path.abspath(sys.argv[0]))
os.path.realpath(sys.argv[0])