''' 我们已经知道,可以直接作用于for循环的数据类型有以下几种: 一类是集合数据类型,如list、tuple、dict、set、str等; 一类是generator,包括生成器和带yield的generator function。 这些可以直接作用于for循环的对象统称为可迭代对象:Iterab ...
分类:
其他好文 时间:
2020-04-02 11:54:00
阅读次数:
71
可变参数(可以不传该参数) #参数numbers接收到的是一个tuple def calc(*numbers): sum = 0 for n in numbers: sum = sum + n * n return sum 关键字参数 def person(name, age, **kw): pri ...
分类:
其他好文 时间:
2020-04-02 11:52:40
阅读次数:
120
```python from collections import namedtuple import os,time import random Query=namedtuple('Query',('y','x')) Transition=namedtuple('Transition',('y',... ...
分类:
编程语言 时间:
2020-04-02 01:30:00
阅读次数:
107
元组 元组是不可变序列,元组一旦创建,用任何方法都不可以修改其元素。 元组的偶有元素是放在一对圆括号“()”中 1.元组创建与删除 使用“=”讲一个元组赋值给变量 >>> tuple=('a','b','c','d','e','f') >>> tuple ('a', 'b', 'c', 'd', ' ...
分类:
编程语言 时间:
2020-04-01 17:53:06
阅读次数:
89
```python 这个问题在Python3.6有时候会出现,说明是源码有bug这一块 Your STATICFILES_DIRS setting is not a tuple or list; " ImproperlyConfigured: Your STATICFILES_DIRS settin... ...
分类:
其他好文 时间:
2020-03-31 23:09:50
阅读次数:
107
今天看见一个烧脑的代码,一时没看懂结果,刨个坑,看懂填 def product(*args, repeat=1): pools = [tuple(pool) for pool in args] * repeat result = [[]] for pool in pools: result = [x ...
分类:
其他好文 时间:
2020-03-31 14:37:53
阅读次数:
48
看C++primer,学习了,看起来还挺有用的。 pair大家都会,但局限性就是只能有两个成员。如果我们想做一个比较随意的、多成员的容器类型,就需要tuple了: int main(){ tuple<int,int,int> p={1,2,3}; p=make_tuple(4,2,56); //对应 ...
分类:
编程语言 时间:
2020-03-31 01:28:06
阅读次数:
74
https://codeforces.com/blog/entry/15643 scanf 可以输入换行符 不会读取换行符 tuple builtin Output pow 今天long long范围内调用了pow函数,然后WA了 改成这样就过了,待解决 ...
分类:
其他好文 时间:
2020-03-28 00:43:17
阅读次数:
61
原文:https://blog.csdn.net/sun2333/article/details/82418326 1、eval可以字符串型的list,tuple,dict转变成原有的类型 (1)string <=> list In [1]: s = '[1, 2, 3, 4]' In [2]: l ...
分类:
其他好文 时间:
2020-03-24 20:23:31
阅读次数:
84