Shebang不会工作

时间:2014-12-19 13:19:29

标签: python python-2.x shebang

我编写了一个小的python脚本,但是bash不会执行它:

#!/usr/bin/python

'''
Created on Dec 19, 2014


'''
import subprocess


if __name__ == '__main__':
    p = subprocess.Popen('df -h', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    out,err = p.communicate()
    for o in out.splitlines():
        if('rootfs' in o):
            print o.split()[3]

当我运行./te.py时,bash给了我一个错误:

-bash: ./te.py: /usr/bin/python^M: bad interpreter: No such file or directory

有什么问题?

1 个答案:

答案 0 :(得分:0)

试试这个:

#!/usr/bin/env python