__file__

__file__ 是 python 的内置变量它的值等于文件名本身

[root@localhost ~]$ cat test.py 
#!/usr/bin/env python
print(__file__)
[root@localhost ~]$ python test.py 
test.py

    

猜你喜欢

转载自www.cnblogs.com/pzk7788/p/10280619.html