Python 怎么获得当前文件的名字

如题所述

用__file__. 如果你想忽略目录(which might be present), 你可以使用os模块
import os
os.path.basename(__file__).
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-12-26
import sys
pyname=sys.argv[0]

相似回答