python學習命令總結
常見的佔位符有:
%d
整數
%f
浮點數
%s
字串
%x
十六進位制整數
=======條件判斷=========elif 是else if 縮寫===========
if <條件判斷1>:
<執行1>
e
elif <條件判斷2>:
<執行2>
e
elif <條件判斷3>:
<執行3>
e
else:
<執行4>
if語句執行有個特點,它是從上往下判斷,如果在某個判斷上是True,把該判斷對應的語句執行後,就忽略掉剩下的elif和else
eg: 輸出結果為 teenager
age = 20
if age >= 6:
print 'teenager'
elif age >= 18:
print 'adult'
else:
print 'kid'
===定義函式====
在Python中,定義一個函式要使用def語句,依次寫出函式名、括號、括號中的引數和冒號:,然後,在縮排塊中編寫函式體,函式的返回值用return語句返回。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28211342/viewspace-2213191/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- python學習總結Python
- Linux命令學習總結:rmdirLinux
- Python NumPy學習總結Python
- Python學習第一週學習總結Python
- MySQL學習筆記之命令總結MySql筆記
- Python Requets庫學習總結Python
- MQ命令學習總結大全MQ常用命令MQ
- Elasticsearch 一些命令彙總 以及學習總結Elasticsearch
- Python---python函式學習總結Python函式
- python學習方法總結(內附python全套學習資料)Python
- git status 命令總結 —— Git 學習筆記 06Git筆記
- Python str型別學習總結(一)Python型別
- 學習總結
- redis原始碼分析(四)、redis命令學習總結—連結串列ListRedis原始碼
- mysqlimport學習總結MySqlImport
- Maven學習總結Maven
- MyBatis 學習總結MyBatis
- awk 學習總結
- JNI 學習總結
- tkinter學習總結
- SVG學習總結SVG
- vue學習總結Vue
- WorkFlow學習總結
- HTML學習總結HTML
- Mybatis學習總結MyBatis
- Kafka 總結學習Kafka
- Typescript學習總結TypeScript
- 【TS】學習總結
- lua 學習總結
- vue 學習總結Vue
- HSF學習總結
- ElasticSearch 學習總結Elasticsearch
- BOM學習總結
- JavaWeb學習總結JavaWeb
- Storm學習總結ORM
- redis學習總結Redis
- JVM學習總結JVM
- Oracle學習總結Oracle