Discuss / Python / 直接运行py文件出现的问题

直接运行py文件出现的问题

Topic source

小O_园子

#1 Created at ... [Delete] [Delete and Lock User]

当文件第一行是这个的时候

#!/user/bin/env python3

在command执行后结果如下 -> chmod a+x hello.py -> ./hello.py -bash: ./hello.py: /user/bin/env: bad interpreter: No such file or directory

后来修改第一行

#!/bin/sh

在command执行结果如下 -> chmod a+x hello.py -> ./hello.py ./hello.py: line 3: syntax error near unexpected token 'hello world'' ./hello.py: line 3:print('hello world')'

我想这个是不是跟bash文件有关系啊?求指教,谢谢!

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]

是 usr 不是 user

小O_园子

#3 Created at ... [Delete] [Delete and Lock User]

啊...好低级的错误啊,谢谢...


  • 1

Reply