字典
dic={'name':'milo','age':25,'gender':'male'}
dic['name']
del(dic['age'])
dic.clear()
del(dic)
dic.get(2)????????????????????????????????? dic.get(5,'error')
help(dict.keys)
dic.keys()
dic.values()
for k in dic:
?print k
?print dic[k]
if expression:
?? statement(s)???????????? 使用4個(gè)空格代替縮進(jìn)
if expression:
??? statement(s)
else:
??? statement(s)
if expression:
??? satement(s)
elseif expression2:
??? statement(s)
elseif expression3:
?? statement(s)
else:
?? statement(s)
x=int(raw_input("please input:"))
if x>=90:
??? print "A"
elseif x>=80:
??? print "B"
else:
?? print "C"
邏輯運(yùn)算符 or??? and??? not
for iteratin_var in sequence:
??? statements(s)
for x in [0,1,2,3,4]:
??? print x,"hello world"
for x in range[100]: 從0到99增長(zhǎng)
fox in in range[1,11,2]:從1到10增長(zhǎng)辑甜,步進(jìn)值2
for遍歷數(shù)據(jù)
s="hellow"
for k in s:
?print kfor k in range(len(s)):
??? print s[k]
dic={1:111,2:222,3:333}
for x in dic:
??? print x???? 輸出key值
??? print dic[x]? 輸出value值
print dic.items()? 輸出全部值
for x,y in dic.items():
??? print x,y? 輸出全部值
? time.sleep(1)延時(shí)1秒
?? for x in range(1,11):
??? print x
??? if x==3:
???????? pass???????????? 占位
??? if x==2:
?????? print "hello 2"
?????? continue???????
??? if x==5:
????? exit()??? 跳出整個(gè)循環(huán)
??? if x==6:
?????? break
???? print "#"*5
else:
??? print "ending"