python基礎-字串、列表、元組、字典
c語言中,
儲存多個數據的方式 陣列,,,int age[10]
while
do-while
for for(int i=0; i<5; i++){ 迴圈條件滿足的時候做的事情 }
const int ***p;
python語言
while
for-in
for temp in 字串等: print(temp)
name[起始位置:結束位置:步長]
字串操作:
if xxxx: yyyyy
True---->表示條件滿足----->真------->非0 False--->表示條件不滿足--->假-------->0
判斷檔案字尾 xxx.endswith("")
.jpg .jepg .gif .png
“您確定要退出嗎?(yes 退出,no不退出)”
yes
YES
Yes yEs yeS
Yes\nyEs\nyeS
op = input("") op.lower()
前端:直接顯示後端傳送過來的資料
content = "hello world" content.center(30)
print("%-2d")
列表:
ages = []
python的列表,可以儲存n個數據,並且每個資料的型別可以任意
元組
(11,22,33,"dongGe",3.14)
字典:
鍵值對
{key鍵:values值,key鍵:values值,key鍵:values值,key鍵:values值}
[[],[],[]] [(),()] [{},{},{}]
作業題1:
nums = [11,232,5,2341,123]
maxNum = 0
for num in nums: xxxx什麼情況下把值賦值為maxNum
作業題2: "hello world"
h:1 e:1 l:3 o:2 d:1 r:1 w:1
選做題:(思考題) 用類似於[{},{}....]的資料,完成儲存一個班級的通訊錄
infos = [{"name":"dongge","age":"30","address":"山東臨沂xxx"}]