用__file__ 来获得脚本所在的路径,比如文件在/root下

cat tee

#!/usr/bin/env python
print __file__              #得到相对路径tee

——————————————————————————————————————

import os
#!/usr/bin/env python
print  os.path.realpath(__file__)                        #得到绝对路径/root/tee

 

相关文章:

  • 2022-01-27
  • 2022-12-23
  • 2021-08-17
  • 2021-06-10
  • 2021-06-07
  • 2022-12-23
猜你喜欢
  • 2021-08-15
  • 2021-05-19
  • 2022-01-03
  • 2021-08-03
  • 2021-05-30
  • 2022-12-23
  • 2022-01-24
相关资源
相似解决方案