python小课堂
sunny__boy
这个作者很懒,什么都没留下…
展开
-
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 评论 -
这些python语句你知道吗?
python的列表推导式 a = [i for i in range(1,5)] print(a) #结果是:[1, 2, 3, 4] Python中的pass语句是什么? 在用Python写代码时,有时可能还没想好函数怎么写,只写了函数声明,但为了保证语法正确,必须输入一些东西,在这种情况下,我们会使用pass语句。 def func(*args): pass 同样,break语句能让我...原创 2020-03-02 23:22:13 · 201 阅读 · 0 评论