變數命名規則

1.必須為英文字、_(底線)、中文字開頭

2.英文字母大小寫視為不同變數

舉例:不合法變數

1. i,1 #變數不可有","

2. 1i #數字不可為開頭

3. i$ #不可有$符號

4. abs() #此為系統保留字

舉例:合法變數

1. i

2. _i

3. i1

4. i_j_1

5. 哈囉

>>> help('keywords')

#列出所有Python的保留字,保留字不可當作變數名稱,否則原先函數功能喪失

Here is a list of the Python keywords.  Enter any keyword to get more help.

False               class               from                 or
None              continue         global              pass
True                def                 if                       raise
and                 del                 import              return
as                    elif                in                       try
assert              else               is                       while
async              except           lambda             with
await              finally            nonlocal            yield
break              for                not

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 愛學習 的頭像
    愛學習

    愛學習

    愛學習 發表在 痞客邦 留言(0) 人氣()