ex1.py文件
# coding: utf-8
print "hello world!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print 'Yay ! Pring.'
print "I'd much rather you 'not'."
print 'I "said" do not touch this.'
print "这是中文输出"
输出语句写法如上
如果不加第一行, 当输出有中文时, 会报出以下错误:
File "ex1.py", line 16
SyntaxError: Non-ASCII character '\xe8' in file ex1.py on line 16, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
以上所述为python2版本, 如果使用python3版本, 输出会有变化, python3将print变成了函数, 输出时, 需要加括号
# coding: utf-8
print("hello world!")
print("Hello Again")
print("I like typing this.")
print("This is fun.")
print('Yay ! Pring.')
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
print("这是中文输出")