如何获取当前模块的文件名

    可以通过特殊变量 file 获取:

    # -- coding:utf-8 --

    # test.py



    print(file)

    输出:

    $ python3 test.py

    test.py