首页 > 编程语言 >2019 年 stackoverflow 网站最受欢迎的 20 个 Python 问题

2019 年 stackoverflow 网站最受欢迎的 20 个 Python 问题

时间:2022-12-20 13:34:02浏览次数:59  
标签:20 Python 2019 questions stackoverflow http com Why

在最新一期的“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​​ - [53/5]
  18. ​Is there a difference between board[x, y\] and board[x][y]​​ - [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))​​ 这个形式的结果?

高票回答是这样:

2019 年 stackoverflow 网站最受欢迎的 20 个 Python 问题_编程语言

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

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

链接清单:

​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​

2019 年 stackoverflow 网站最受欢迎的 20 个 Python 问题_运算符_02

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



标签:20,Python,2019,questions,stackoverflow,http,com,Why
From: https://blog.51cto.com/u_14244765/5954751

相关文章

  • Python 官方团队在打包项目中踩过的坑
    花下猫语:这是packaging系列的第三篇译文,该系列是全网关于此话题的最详尽(水平也很高)的一个系列。原作者是Python官方打包团队成员,是virtualenv和tox项目的维护者,及s......
  • Python 打包——过去、现在与未来
    英文|​​Pythonpackaging-Past,Present,Future​​【1】原作|BERNATGABOR译者|豌豆花下猫声明:本文获得原作者授权翻译,转载请保留原文出处,请勿用于商业或非法......
  • 我的 2019 年 Python 文章榜单
    现在是2020年的第一天,我相信从昨天开始,各位的信息流里肯定充斥了各式各样的年度盘点/回顾/总结/记录之类的内容。虽然来得稍晚了,但我还是想给诸位送上这一篇文章。我将在......
  • Python 3 既是激进的又是克制的,这些提议被否决了
    [译]PEP3099--Python3中不会改变的事情导语:Python3.8已经发布了,引进了不少变更点。关于3.9预计引入的修改,也披露了一些。我们之前还关注过​​GIL的移除计划​​......
  • Python 为什么要保留显式的 self ?
    花下猫语:前两天,我偶然在一个(刘欣老师的“码农翻身”)里看到一篇主题,刘老师表示Python的类方法非要带个self,而不像其它语言那样隐藏起来,这让人很不爽。我对此也有同感。在......
  • 更好用的 Python 任务自动化工具:nox 官方教程
    英文|​​noxtutorial​​​译者|豌豆花下猫@Python猫Github地址:​​https://github.com/chinesehuazhou/nox_doc_cn​​声明:本翻译基于​​CCBY-NC-SA4.0​​授权协议......
  • Python 任务自动化工具:nox 的配置与 API
    英文|​​Configuration&API​​​译者|豌豆花下猫@Python猫Github地址:​​https://github.com/chinesehuazhou/nox_doc_cn​​声明:本翻译基于CCBY-NC-SA4.0授权协......
  • PYTHON - openpyxl (四)
    1.1字体Font类型:openpyxl.styles.fonts.Fontsheet["a1"].font=Font(name='字体',size=字号,...)name字体,中文字体前面加usize字号大小bold=True/False粗......
  • 最新版Photoshop 2023更新 (ps 2023) for Mac 支持M1 v24.0激活版
    Photoshop2023是一款电脑必备修图工具,该版本已经更新到ps2023版!最新的ps2023帮助你组合、修饰和重新混合您的照片,为您的旧黑白添加新颜色,或者让不需要的东西消失,也或者将......
  • 用Python写一个一次性计算出加减乘除的运算小程序
    0x1前言跟上一个购物车一样的玩法,也都挺简单的,看标题意思就懂了,不做多介绍了0x2加减乘除的运算小程序importre#处理字符串中的符号defsign_exp(strvar):s......