在最新一期的“Python开发者周刊”(Pycoder's weekly)里,我看到一则有意思的分享,故转出来分享给大家。

该分享来自是一份”python weekly reports“,统计了 2019 年里 stackoverflow 网站上支持数最高的 20 个问题。问题列表如下(方括号中的两个数字是其支持数与回答数):

  1. Why does Python's hash of infinity have the digits of π? - [236/3]
  2. Is there a more elegant way to express ((x == a and y == b) or (x == b and y == a))? - [105/10]
  3. Why can I use a list index as an indexing variable in a for loop? - [92/6]
  4. Why does (inf + 0j)*1 evaluate to inf + nanj? - [93/4]
  5. Why is f'{{{74}}}' the same as f'{{74}}' with f-Strings? - [88/1]
  6. Why does b+=(4,) work and b = b + (4,) doesn't work when b is a list? - [75/7]
  7. Why does Python start at index -1 (as opposed to 0) when indexing a list from the end? - [79/7]
  8. Why is TensorFlow 2 much slower than TensorFlow 1? - [104/2]
  9. Randomness of Python's random - [70/4]
  10. Why does Python allow out-of-range slice indexes for sequences? - [72/2]
  11. Unexpected behaviour with Python generator - [57/8]
  12. What exactly is meant by "partial function" in functional programming? - [55/3]
  13. What does a yield inside a yield do? - [56/4]
  14. Issues implementing the "Wave Collapse Function" algorithm in Python 2.7 - [52/2]
  15. Should linear read-shuffled write always be faster than shuffled read-linear write? (Was: Why is fancy assignment slower than fancy lookup?) - [53/5]
  16. How to write 2**n - 1 as a recursive function? - [49/7]
  17. Why is a for loop so much faster to count True values? - [53/5]
  18. Is there a difference between board[x, y\] and board[x][y] in Python? - [47/6]
  19. Why was p[:] designed to work differently in these two situations?- [51/6]
  20. Jupyter notebook: No connection to server because websocket connection fails - [46/4]

不用怀疑,这些内容的支持数和回答数就是那么少。不过也需注意,它统计的是问题本身的支持数,而不是回答的支持数(尽管回答的支持数也很少)。

还有一点需注意,这份报告并非 stackoverflow 网站的官方报告,而且文中也未说明统计口径与筛选标准,所以我们姑且一看。

有些问题可能挺怪的,或者平时不大可能考虑到,比如关于列表的两个问题:为什么从列表末尾查找时是从 -1 开始?为什么列表的切片允许越界?

不少回答都挺有专业精神,往往会带来新的视角和知识信息。比如,关于列表的 -1 索引问题,高票回答中提到了“~”运算符,有这样的用法:

arr = ["a", "b", "c", "d"]
print(arr[~0]) # d
print(arr[~1]) # c

让人眼前一亮!

还有一个问题是:如何优雅地计算 ((x == a and y == b) or (x == b and y == a)) 这个形式的结果?

高票回答是这样:

初一看,就像看人变戏法一样……

其它问题和回答就不一一说明了,建议感兴趣的同学按图索骥,按部就班,顺藤摸瓜,顺手牵羊……

链接清单:

https://python-weekly.blogspot.com/2020/01/20-best-python-questions-at.html?m=1

[1] http://stackoverflow.com/questions/56227419

[2] http://stackoverflow.com/questions/58435645

[3] http://stackoverflow.com/questions/55644201

[4] http://stackoverflow.com/questions/58031966

[5] http://stackoverflow.com/questions/59359911

[6] http://stackoverflow.com/questions/58259682

[7] http://stackoverflow.com/questions/55684960

[8] http://stackoverflow.com/questions/58441514

[9] http://stackoverflow.com/questions/55934019

[10] http://stackoverflow.com/questions/54613753

[11] http://stackoverflow.com/questions/54245618

[12] http://stackoverflow.com/questions/58339040

[13] http://stackoverflow.com/questions/55922302

[14] http://stackoverflow.com/questions/57049191

[15] http://stackoverflow.com/questions/54782033

[16] http://stackoverflow.com/questions/58378549

[17] http://stackoverflow.com/questions/56288015

[18] http://stackoverflow.com/questions/57351363

[19] http://stackoverflow.com/questions/56782148

[20] http://stackoverflow.com/questions/54963043

公众号【Python猫】, 本号连载优质的系列文章,有喵星哲学猫系列、Python进阶系列、好书推荐系列、技术写作、优质英文推荐与翻译等等,欢迎关注哦。

2019 年 stackoverflow 网站最受欢迎的 20 个 Python 问题的更多相关文章

  1. C#不用union,而是有更好的方式实现 .net自定义错误页面实现 .net自定义错误页面实现升级篇 .net捕捉全局未处理异常的3种方式 一款很不错的FLASH时种插件 关于c#中委托使用小结 WEB网站常见受攻击方式及解决办法 判断URL是否存在 提升高并发量服务器性能解决思路

    C#不用union,而是有更好的方式实现   用过C/C++的人都知道有个union,特别好用,似乎char数组到short,int,float等的转换无所不能,也确实是能,并且用起来十分方便.那C# ...

  2. 2017年StackOverflow上最好的20个Python问题

    1.Python的 .. (点号 点号) 是什么语法? 答案地址:https://stackoverflow.com/questions/43487811/what-is-python-dot-dot ...

  3. Linux运维之——每日小技巧,获取网站请求数的前20个IP

    获取网站请求书的前20个IP |grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20

  4. 2019年10个最受欢迎的JavaScript动画库!

    摘要: 非常炫酷的动画库! 原文:值得看看,2019 年 11 个受欢迎的 JavaScript 动画库! 作者:前端小智 Fundebug经授权转载,版权归原作者所有. 1. Three.js 超过 ...

  5. WEB网站常见受攻击方式及解决办法

    一个网站建立以后,如果不注意安全方面的问题,很容易被人攻击,下面就讨论一下几种漏洞情况和防止攻击的办法. 一.跨站脚本攻击(XSS) 跨站脚本攻击(XSS,Cross-site scripting)是 ...

  6. 【转】WEB网站常见受攻击方式及解决办法

    一个网站建立以后,如果不注意安全方面的问题,很容易被人攻击,下面就讨论一下几种漏洞情况和防止攻击的办法. 一.跨站脚本攻击(XSS) 跨站脚本攻击(XSS,Cross-site scripting)是 ...

  7. 什么样子的WordPress网站更受搜索引擎欢迎

    网站的导航功能对于搜索引擎而言是非常重要的 网站的导航功能对于帮助用户迅速找到他们想要的内容来说是很重要的.它对帮助搜索引擎理解该网站有哪些重要内容同样非常重要.虽然百度的搜索结果都是指向每一个特定的 ...

  8. 最受欢迎的15个Python开源框架

    GitHub中15个最受欢迎的Python开源框架.这些框架包括事件I/O,OLAP,Web开发,高性能网络通信,测试,爬虫等. 1.Django: Python Web应用开发框架 Django 应 ...

  9. 探讨2018年最受欢迎的15顶级Python库!

    近日,数据科学网站 KDnuggets 评选出了顶级 Python 库 Top15,领域横跨数据科学.数据可视化.深度学习和机器学习.如果本文有哪些遗漏,你可以在评论区补充. 图 1:根据 GitHu ...

随机推荐

  1. [kuangbin带你飞]专题九 连通图C - Critical Links UVA - 796

    这道题就是要求桥的个数. 那么桥相应的也有判定的定理: 在和u相邻的节点中,存在一个节点是最小的时间戳都比 当前u的访问次序要大,也就是说这个点是只能通过果u到达,那么 他们之间相邻的边就是的桥 #i ...

  2. css的一些小问题

    这是今天整理的笔记一.属性书写顺序: Formatting Model(布局方式.位置) > Box Model(尺寸) > Typographic(文本相关) > Visual(视 ...

  3. cccc初赛 L3-003 长城

    L3-009. 长城 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 邓俊辉 正如我们所知,中国古代长城的建造是为了抵御外敌入侵.在长 ...

  4. 1471 - Defense Lines

    After the last war devastated your country, you - as the king of the land of Ardenia - decided it wa ...

  5. P1039 大规模间谍入侵

    题目描述 爱丽丝魔法王国成立10周年,于是决定矩形国庆大阅兵. 在国庆大阅兵期间,为了防止暗黑王国的间谍乔装成平民混入,需要对每一个进城的人做检测. 因为暗黑王国的人长得和爱丽丝魔法王国的人长得很像, ...

  6. webpack4.0基本配置,超简单!

    最近复习了一下webpack,使用的是4.0版本. 下图是基本目录结构,最后留有代码地址,有兴趣可以去看看. 直接上代码(依赖未完全使用): 项目的所有依赖都可以安装,每个都有详细的注释.] cons ...

  7. ZOJ Problem Set - 1090——The Circumference of the Circle

      ZOJ Problem Set - 1090 The Circumference of the Circle Time Limit: 2 Seconds      Memory Limit: 65 ...

  8. Libra和中国央行数字货币(DCEP)的对比

    最近偶然和朋友讨论起Libra,对Libra和央行的数字货币方案很感兴趣.梳理了阅读资料(参考见文末)和自己的思考,发知乎留个记录. Libra 是什么? 无国界货币 + 为全球数十亿人服务的金融基础 ...

  9. k8s的网络方案对比

    如下图,三台虚拟机k8s-master.k8s-node-1.k8s-node-2组成k8s集群,网络拓扑和节点IP分配如下图: 一.flannel组网方案 https://github.com/co ...

  10. Visual Studio Team Services使用教程【6】:Readers tfs组checkin权限修改

    你也可以只开启部分代码的权限 把上面开启的整个应用的权限先去掉 只开启一个文件的权限 2017.4.23之后建议朋友看下面的帖子 TFS2017 & VSTS 实战(繁体中文视频) Visua ...