Python學習-4-基礎知識點(未完待續)

1、基礎語法java

一、註釋:#註釋,在eclipse中能夠用Ctrl+/快捷鍵python

#!/usr/bin/python3
 
# 第一個註釋
# 第二個註釋
 
'''
第三註釋
第四註釋
'''
 
"""
第五註釋
第六註釋
"""
print ("Hello, Python!")

二、標識符:字母數字下劃線,同java,數字不能打頭;大小寫敏感eclipse

三、保留字:spa

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

四、行縮進code

python最具特點的就是使用縮進來表示代碼塊,不須要使用大括號 {} 。縮進的空格數是可變的,可是同一個代碼塊的語句必須包含相同的縮進空格數。three

五、多行語句ip

Python 一般是一行寫完一條語句,但若是語句很長,咱們能夠使用反斜槓(\)來實現多行語句字符串

total = item_one + \
        item_two + \
        item_three

在 [], {}, 或 () 中的多行語句,不須要使用反斜槓(\),例如:it

total = ['item_one', 'item_two', 'item_three',
        'item_four', 'item_five']

數字(Number)類型

python中數字有四種類型:整數、布爾型、浮點數和複數。class

  • int (整數), 如 1, 只有一種整數類型 int,表示爲長整型,沒有 python2 中的 Long。
  • bool (布爾), 如 True。
  • float (浮點數), 如 1.2三、3E-2
  • complex (複數), 如 1 + 2j、 1.1 + 2.2j

字符串(String)

  • python中單引號和雙引號使用徹底相同。
  • 使用三引號('''或""")能夠指定一個多行字符串。
相關文章
相關標籤/搜索