新建ex1.py
print "Hello World!" print "Hello Yang" print "I like typing this." print "This is fun." print 'Yay! Printing.' print "I'd much rather you 'not'." print 'I "said" do not touch this.'
执行命令:python ex1.py 结果如下:
[root@yang mystuff]# python ex1.py
hello world!
hello Again
I like typing this.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
如果有如下类似错误信息:
File "ex/ex1.py",line 3
^
print "I like typing this.
SyntaxError:EOL while scanning string literal
SyntaxError:语法错误,这样一般来说为编码错误,即可以在脚本最上面加入
#-*-coding:utf-8-*- 就可以避免上述错误。