2016-05-11 44 views
-5

這些變量導致語法錯誤:變量導致語法錯誤沒有很好的理由

1point = "AJS" 
2points = "BKT" 
3points = "CLU" 
4points = "DMV" 
5points = "ENW" 
6points = "FOX" 
7points = "GPY" 
8points = "HQZ" 
9points = "IR" 

我想要的程序繼續運行,但它得到停留在「1點」

+0

Python變量**不能**以數字開頭。 –

+0

變量名稱不能以整數開頭。將數字移到最後。 – zondo

+0

opps對不起!我想這是一個noob錯誤。好吧,我們每天都會學到新的東西! – ThePlumBOB179

回答

1

Python變量名可以只能從下劃線或字母開始,而不是數字。數字可以在名字的任何其他地方使用,只是不在開始。

Identifiers and keywords section

Within the ASCII range (U+0001..U+007F), the valid characters for identifiers are the same as in Python 2.x: the uppercase and lowercase letters A through Z, the underscore _ and, except for the first character, the digits 0 through 9.

大膽重點煤礦。 Python 3支持Unicode變量名,因此可以使用ASCII範圍以外的字符。請參閱上面的鏈接瞭解詳細信息。