python小课堂,开课了!
Python的小知识
获取 list 里的某一个值
a_list = [‘a’,‘b’,‘c’,‘hello’]
a_list.index(‘a’) #返回a在列表中出现的位置
a_list.index(‘a’,0,3) #返回a在某个区间出现的位置
a_list.count(‘a’) #返回a在列表中出现的次数
dict的查找
a_dict = {‘name’:‘小小’,‘age’:12}
a_dict.get(‘name’) #返回值
a_dict[‘name’] #返回值
如果
原创
2020-10-10 16:02:35 ·
134 阅读 ·
0 评论