閱讀893 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Python 3 學習之路 (1)變量,用戶交互,if else , while ,for

Python3

1.變量
無須指定類型,python 默認變量類型微str
name = "hello"

查看變量類型函數

變量的強製轉換
age = 10
age = int(age)

2.用戶交互
name = input("please input a name :") #input會阻塞,等待用戶輸入完成回車

3.if else

if 條件(and | or): #注意行尾是冒號,與邏輯寫成and
    代碼塊   #縮進4個空格位
elif 條件:
    代碼塊       
else :
    代碼塊       ```

4.while循環

while 條件:

代碼塊```

5.for循環

for 變量 in 數組:

    代碼塊```  

6.continue   
7. break

最後更新:2017-05-15 12:31:08

  上一篇:go  即學即用:Pandas入門與時間序列分析
  下一篇:go  史上最全解讀WanaCrypt0r 2.0勒索軟件及安全防護最佳實踐