摘要:
>>> spam='Hello world' >>> spam.upper() #所有字母被转为大写 'HELLO WORLD' >>> spam.lower() #所有字母被转为小写 'hello world' >>> spam #未改变原字符串 'Hello world' >>> spam.is 阅读全文
posted @ 2023-02-15 20:40
Lucass-
阅读(27)
评论(0)
推荐(0)
摘要:
allGuests={'Alice':{'apples':5,'pretzels':12}, 'Bob':{'ham sandwiches':3,'apples':2}, 'Carol':{'cups':3,'apple pies':1}} def total(x,y): num=0 for k,v 阅读全文
posted @ 2023-02-15 19:25
Lucass-
阅读(17)
评论(0)
推荐(0)
摘要:
①单个字符 message='It was a bright cold day in April,and the clocks were striking thirteen.' count={} for i in message: count.setdefault(i,0) count[i]=cou 阅读全文
posted @ 2023-02-15 17:08
Lucass-
阅读(57)
评论(0)
推荐(0)
摘要:
# 字典输入使用{} >>> cat={'size':'big','color':'white'} #‘size’、‘color’为键 >>> cat['size'] #可通过键访问值 'big' >>> spam={123:'aaa',46:'bb'} >>> spam[123] #可以用整数做键 阅读全文
posted @ 2023-02-15 17:05
Lucass-
阅读(19)
评论(0)
推荐(0)

浙公网安备 33010602011771号