![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
tips
steadyfirmness
这个作者很懒,什么都没留下…
展开
-
Python - 迭代器陷阱
前言运用赋值表达式(海象运算符 - python3.8特性)时想要把表达式结果赋值一个变量a = []a.extend(((temp := map(lambda x:x*2, [1,2]))))#temp想捕获这个map返回的迭代器print(list(temp))# [] 疑问这里的temp难道不是[2, 4]吗?一度以为是海象运算符的问题,于是type(temp)#确实是迭代器类型list(temp)#确实还是[]type(map(lambda x:x*2, [1,2]))#确实原创 2021-10-21 13:08:09 · 159 阅读 · 0 评论 -
8月18刷题记录
python连续赋值的易错点形如:a,b = c,d赋值依然存在顺序,以下为执行顺序的说明temp1 = ctemp2 = da = temp1b = temp2举例:a,a = 4,5#a = 5a,b = 1,a#a = 1#b = 5原创 2021-10-02 11:50:37 · 126 阅读 · 0 评论