Python基礎練習(ex1.py)

新建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-*-  就可以避免上述錯誤。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章