初学python遇到的一个问题

PonyCheng2019 2013-09-02 11:29:22
代码如下:
#/usr/bin/env python

"this is a test module"

import sys
import os

print __name__
debug = False

class FooClass(object) :
"Foo class"

def test():
"test function"
foo = FooClass()
if debug:
print 'ran test()'
else:
print 'no debug'

if __name__ == '__main__':
test()

当我用./xxx.py执行该代码的时候出现./typical_python_src.py: line 3: this is a test module: command not found,而使用python xxx.py时能执行成功,初学python,希望谁能帮助一下,谢谢。
...全文
80 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
PonyCheng2019 2013-09-02
  • 打赏
  • 举报
回复
引用 1 楼 panghuhu250 的回复:
第一行开头应该是"#!"。没有"!",系统把它当成shell script执行了。
额,大意了,谢谢。。。
panghuhu250 2013-09-02
  • 打赏
  • 举报
回复
第一行开头应该是"#!"。没有"!",系统把它当成shell script执行了。

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧