Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/taizilongxu/stackoverflow_python

stackoverflow上关于python的翻译
https://github.com/taizilongxu/stackoverflow_python

python stackoverflow

Last synced: about 1 month ago
JSON representation

stackoverflow上关于python的翻译

Awesome Lists containing this project

README

        

# Stackoverflow 上关于 Python 的问题
[![](https://img.shields.io/github/stars/taizilongxu/stackoverflow_python.svg?style=for-the-badge&label=Stars)](https://github.com/taizilongxu/stackoverflow_python)

排名根据 vote 数量选取, 许多 SO 上的回答质量确实高, 有能力建议查看原文, 一般引用的文章也非常好,

翻译是根据 question id 写在 data 文件夹, 运行脚本 `get_so_100.py` 自动生成 `part` 部分文档

## 目录

> 图表数据更新时间 2020-08-05 19:08:23

| rank | vote | view | answer | url |中文|
|:-:|:-:|:-:|:-:|:-:|:-|
|1|10373|2269693|41|[url](http://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do)|[Python中关键字yield有什么作用?](part/1.md)|
|2|6191|3048629|33|[url](http://stackoverflow.com/questions/419163/what-does-if-name-main-do)|[`if __name__ == "__main__":`有什么作用?](part/2.md)|
|3|6154|1947774|26|[url](http://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator)|[在Python中有三元运算符吗?](part/3.md)|
|4|5788|812265|22|[url](http://stackoverflow.com/questions/100003/what-are-metaclasses-in-python)|[Python中的元类(metaclass)是什么?](part/4.md)|
|5|5697|3946153|39|[url](http://stackoverflow.com/questions/82831/how-do-i-check-whether-a-file-exists-without-exceptions)|[用Python如何一个文件是否存在?](part/5.md)|
|6|4963|3468096|61|[url](http://stackoverflow.com/questions/89228/calling-an-external-command-from-python)|[在Python中调用外部命令?](part/6.md)|
|7|4934|1901070|44|[url](http://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression-in-python-taking-union-o)|[如何在一个表达式里合并两个字典?](part/7.md)|
|8|4324|2684453|25|[url](http://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory)|[检查一个文件夹是否存在,如果不存在就创建它](part/8.md)|
|9|3684|2171883|21|[url](http://stackoverflow.com/questions/522563/accessing-the-index-in-for-loops)|[在循环中获取索引(数组下标)](part/9.md)|
|10|3647|795254|27|[url](http://stackoverflow.com/questions/136097/difference-between-staticmethod-and-classmethod)|[装饰器@staticmethod和@classmethod有什么区别?](part/10.md)|
|11|3599|4214927|10|[url](http://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method)|[Python中有检查字符串包含的方法吗?](part/11.md)|
|12|3494|2274525|41|[url](http://stackoverflow.com/questions/952914/how-to-make-a-flat-list-out-of-list-of-lists)|[在嵌套列表中获取 flat list](part/12.md)|
|13|3472|4533564|21|[url](http://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory)|[在Python中列出目录中的所有文件](part/13.md)|
|14|3420|2948940|34|[url](http://stackoverflow.com/questions/613183/how-do-i-sort-a-dictionary-by-value)|[用字典的值(key)对字典进行排序](part/14.md)|
|15|3400|1805051|33|[url](http://stackoverflow.com/questions/509211/understanding-slice-notation)|[理解Python切片](part/15.md)|
|16|3261|3993138|30|[url](http://stackoverflow.com/questions/176918/finding-the-index-of-an-item-in-a-list)|[查找列表中某个元素的下标](part/16.md)|
|17|3234|2979757|27|[url](http://stackoverflow.com/questions/53513/how-do-i-check-if-a-list-is-empty)|[检查列表是否为空的最好方法](part/17.md)|
|18|3209|4373538|12|[url](http://stackoverflow.com/questions/3294889/iterating-over-dictionaries-using-for-loops)|[使用 for 来迭代字典的原理](part/18.md)|
|19|3172|3231767|19|[url](http://stackoverflow.com/questions/423379/using-global-variables-in-a-function)|[如何在一个函数里用全局变量?](part/19.md)|
|20|3116|2973556|20|[url](http://stackoverflow.com/questions/252703/what-is-the-difference-between-pythons-list-methods-append-and-extend)|[Python中的appen和extend](part/20.md)|
|21|2965|3365658|42|[url](http://stackoverflow.com/questions/415511/how-to-get-the-current-time-in-python)|[在Python里获取当前时间](part/21.md)|
|22|2822|857366|5|[url](http://stackoverflow.com/questions/6470428/catch-multiple-exceptions-in-one-line-except-block)|[在一行里获取多个异常](part/22.md)|
|23|2775|681510|22|[url](http://stackoverflow.com/questions/1436703/difference-between-str-and-repr)|[`__str__`和`repr__`的区别](part/23.md)|
|24|2774|523338|17|[url](http://stackoverflow.com/questions/739654/how-to-make-a-chain-of-function-decorators)|[Python中如何在一个函数中加入多个装饰器?](part/24.md)|
|25|2774|3086312|13|[url](http://stackoverflow.com/questions/510348/how-can-i-make-a-time-delay-in-python)|[在 Python 里如何手工进行延迟?](part/25.md)|
|26|2686|3539652|16|[url](http://stackoverflow.com/questions/1024847/how-can-i-add-new-keys-to-a-dictionary)|[字典里添加元素的方法](part/26.md)|
|27|2683|3728780|16|[url](http://stackoverflow.com/questions/1602934/check-if-a-given-key-already-exists-in-a-dictionary)|[检查一个键在字典中是否存在](part/27.md)|
|28|2676|1390524|27|[url](http://stackoverflow.com/questions/986006/how-do-i-pass-a-variable-by-reference)|[怎么用引用来改变一个变量?](part/28.md)|
|29|2631|158732|31|[url](http://stackoverflow.com/questions/1132941/least-astonishment-and-the-mutable-default-argument)|[Python中的"小震撼":变化的默认参数](part/29.md)|
|30|2616|1726238|22|[url](http://stackoverflow.com/questions/2612802/list-changes-unexpectedly-after-assignment-how-do-i-clone-or-copy-it-to-prevent)|[如何克隆或者 copy 一个 list ?](part/30.md)|
|31|2598|2628372|24|[url](http://stackoverflow.com/questions/1720421/how-do-i-concatenate-two-lists-in-python)|[合并两个列表](part/31.md)|
|32|2573|1723365|7|[url](http://stackoverflow.com/questions/576169/understanding-python-super-with-init-methods)|[理解Python中`super()`和`__init__()`方法](part/32.md)|
|33|2565|2031233|16|[url](http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python)|[复制文件](part/33.md)|
|34|2554|3044670|38|[url](http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows)|[怎么在windows下安装pip?](part/34.md)|
|35|2414|741311|22|[url](http://stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters)|[Python中`**`和`*`参数有什么用?](part/35.md)|
|36|2411|2586996|19|[url](http://stackoverflow.com/questions/606191/convert-bytes-to-a-string)|[bytes 换成 string](part/36.md)|
|37|2408|1215558|12|[url](http://stackoverflow.com/questions/448271/what-is-init-py-for)|[`__init__.py` 的作用](part/37.md)|
|38|2327|978966|64|[url](http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks)|[在Python怎么样才能把列表分割成同样大小的块?](part/38.md)|
|39|2323|1804194|8|[url](http://stackoverflow.com/questions/2052390/manually-raising-throwing-an-exception-in-python)|[手动抛出异常](part/39.md)|
|40|2284|3966336|28|[url](http://stackoverflow.com/questions/379906/how-do-i-parse-a-string-to-a-float-or-int)|[把字符串解析成浮点数或者整数](part/40.md)|
|41|2257|3097215|13|[url](http://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory)|[查找当前目录和文件目录](part/41.md)|
|42|2215|3027686|20|[url](http://stackoverflow.com/questions/466345/converting-string-into-datetime)|[把字符串转化成时间](part/42.md)|
|43|2199|2049948|13|[url](http://stackoverflow.com/questions/6996603/how-to-delete-a-file-or-folder)|[删除文件或者文件夹](part/43.md)|
|44|2195|1299936|45|[url](http://stackoverflow.com/questions/287871/how-to-print-colored-text-in-python)|[怎么在终端里输出颜色?](part/44.md)|
|45|2191|3006128|14|[url](http://stackoverflow.com/questions/663171/how-do-i-get-a-substring-of-a-string-in-python)|[获得一个字符串的子串](part/45.md)|
|46|2177|1871474|11|[url](http://stackoverflow.com/questions/4906977/how-to-access-environment-variable-values)|[ 在 Python 中如何获取环境变量](part/46.md)|
|47|2165|206370|10|[url](http://stackoverflow.com/questions/30081275/why-is-1000000000000000-in-range1000000000000001-so-fast-in-python-3)|[为什么 "1000000000000000 in range(1000000000000001)" 在 Python3 里速度那么快?](part/47.md)|
|48|2132|2911412|17|[url](http://stackoverflow.com/questions/332289/how-do-you-change-the-size-of-figures-drawn-with-matplotlib)|[如何改变 matplotlib 图像大小](part/48.md)|
|49|2121|2187007|12|[url](http://stackoverflow.com/questions/930397/getting-the-last-element-of-a-list)|[获取列表最后一个元素](part/49.md)|
|50|2096|1246185|55|[url](http://stackoverflow.com/questions/2720014/how-to-upgrade-all-python-packages-with-pip)|[用pip升级所有包](part/50.md)|
|51|2092|632450|23|[url](http://stackoverflow.com/questions/101754/is-there-a-way-to-run-python-on-android)|[有方法让Python运行在Android上吗?](part/51.md)|
|52|2091|2439201|5|[url](http://stackoverflow.com/questions/6797984/how-do-i-lowercase-a-string-in-python)|[在 Python 中如何将字符串转回为小写](part/52.md)|
|53|2090|2734719|22|[url](http://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas)|[](part/53.md)|
|54|2069|2976076|10|[url](http://stackoverflow.com/questions/17071871/how-to-select-rows-from-a-dataframe-based-on-column-values)|[](part/54.md)|
|55|2027|3678001|28|[url](http://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list)|[把文件一行行读入数组](part/55.md)|
|56|1970|1218914|21|[url](http://stackoverflow.com/questions/68645/are-static-class-variables-possible-in-python)|[Python 中类的静态变量](part/56.md)|
|57|1955|3290422|9|[url](http://stackoverflow.com/questions/1712227/how-do-i-get-the-number-of-elements-in-a-list)|[怎么样获取一个列表的长度?](part/57.md)|
|58|1939|764091|18|[url](http://stackoverflow.com/questions/72899/how-do-i-sort-a-list-of-dictionaries-by-a-value-of-the-dictionary)|[通过列表中字典的值对列表进行排序](part/58.md)|
|59|1894|2898051|27|[url](http://stackoverflow.com/questions/11346283/renaming-columns-in-pandas)|[](part/59.md)|
|60|1893|1895582|22|[url](http://stackoverflow.com/questions/493386/how-to-print-without-newline-or-space)|[如何使打印的内容没有空格或换行](part/60.md)|
|61|1870|259761|10|[url](http://stackoverflow.com/questions/9371238/why-is-reading-lines-from-stdin-much-slower-in-c-than-python)|[为什么在C++中读取stdin中的行会比Python慢呢?](part/61.md)|
|62|1844|1520739|13|[url](http://stackoverflow.com/questions/11277432/how-to-remove-a-key-from-a-python-dictionary)|[ 在 Python 中如何移除字典中的 key ?](part/62.md)|
|63|1807|1765599|13|[url](http://stackoverflow.com/questions/2225038/determine-the-type-of-an-object)|[查看一个对象的类型](part/63.md)|
|64|1791|1428391|14|[url](http://stackoverflow.com/questions/306400/how-to-randomly-select-an-item-from-a-list)|[在列表中随机取一个元素](part/64.md)|
|65|1781|1289586|10|[url](http://stackoverflow.com/questions/493819/why-is-it-string-joinlist-instead-of-list-joinstring)|[为什么是string.join(list)而不是list.join(string)?](part/65.md)|
|66|1779|726218|14|[url](http://stackoverflow.com/questions/3061/calling-a-function-of-a-module-by-using-its-name-a-string)|[通过函数名的字符串来调用这个函数](part/66.md)|
|67|1740|975262|10|[url](http://stackoverflow.com/questions/735975/static-methods-in-python)|[静态方法](part/67.md)|
|68|1718|1588422|44|[url](http://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python)|[Python中用什么代替switch语句?](part/68.md)|
|69|1716|3370415|26|[url](http://stackoverflow.com/questions/455612/limiting-floats-to-two-decimal-points)|[限制浮点型到小数点后两位](part/69.md)|
|70|1709|1870588|28|[url](http://stackoverflow.com/questions/275018/how-can-i-remove-a-trailing-newline)|[如何移除换行符?](part/70.md)|
|71|1679|895303|14|[url](http://stackoverflow.com/questions/610883/how-to-know-if-an-object-has-an-attribute-in-python)|[在 Python 中如何得到对象的所有属性?](part/71.md)|
|72|1675|2173501|21|[url](http://stackoverflow.com/questions/17271319/how-do-i-install-pip-on-macos-or-os-x)|[在 macOS 上如何安装 pip](part/72.md)|
|73|1649|930869|12|[url](http://stackoverflow.com/questions/990754/how-to-leave-exit-deactivate-a-python-virtualenv)|[如何离开/退出/停用Python的virtualenv?](part/73.md)|
|74|1636|1393338|33|[url](http://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float)|[检查一个字符串是否是一个数字](part/74.md)|
|75|1615|2691500|16|[url](http://stackoverflow.com/questions/402504/how-to-determine-a-python-variables-type)|[ 如何查看 Python 变量的类型?](part/75.md)|
|76|1614|623581|12|[url](http://stackoverflow.com/questions/12179271/meaning-of-classmethod-and-staticmethod-for-beginner)|[对于初学者如何理解 `@classmethod` 和 `@staticmethod`?](part/76.md)|
|77|1604|1634991|12|[url](http://stackoverflow.com/questions/4706499/how-do-you-append-to-a-file-in-python)|[如何增加文件的内容?](part/77.md)|
|78|1568|463004|16|[url](http://stackoverflow.com/questions/5466451/how-can-i-print-literal-curly-brace-characters-in-python-string-and-also-use-fo)|[如何在 .format 中使用大括号?](part/78.md)|
|79|1561|1740379|24|[url](http://stackoverflow.com/questions/2600191/how-can-i-count-the-occurrences-of-a-list-item)|[如何计算列表中元素出现的个数?](part/79.md)|
|80|1541|2672492|18|[url](http://stackoverflow.com/questions/627435/how-to-remove-an-element-from-a-list-by-index)|[如何删除 list 中指定 index 的元素?](part/80.md)|
|81|1489|1661305|22|[url](http://stackoverflow.com/questions/1450393/how-do-you-read-from-stdin)|[在 Python 里如何读取 stdin?](part/81.md)|
|82|1484|936725|17|[url](http://stackoverflow.com/questions/339007/how-to-pad-zeroes-to-a-string)|[给字符串填充0](part/82.md)|
|83|1477|1563435|28|[url](http://stackoverflow.com/questions/4383571/importing-files-from-different-folder)|[](part/83.md)|
|84|1472|971303|9|[url](http://stackoverflow.com/questions/510972/getting-the-class-name-of-an-instance)|[如何获取实例的类名](part/84.md)|
|85|1459|1657131|15|[url](http://stackoverflow.com/questions/5844672/delete-an-element-from-a-dictionary)|[](part/85.md)|
|86|1450|1764723|25|[url](http://stackoverflow.com/questions/9573244/how-to-check-if-the-string-is-empty)|[检查字符串为空的最优雅的方法](part/86.md)|
|87|1445|2640604|9|[url](http://stackoverflow.com/questions/2835559/why-cant-python-parse-this-json-data)|[如何解析一个 JSON 文件?](part/87.md)|
|88|1426|868944|11|[url](http://stackoverflow.com/questions/3394835/use-of-args-and-kwargs)|[`*args`和 `**kwargs`](part/88.md)|
|89|1418|682095|191|[url](http://stackoverflow.com/questions/101268/hidden-features-of-python)|[](part/89.md)|
|90|1407|1851506|15|[url](http://stackoverflow.com/questions/13411544/delete-column-from-pandas-dataframe)|[](part/90.md)|
|91|1379|3422957|12|[url](http://stackoverflow.com/questions/961632/converting-integer-to-string)|[整数转化为字符串](part/91.md)|
|92|1367|1933416|19|[url](http://stackoverflow.com/questions/3996904/generate-random-integers-between-0-and-9)|[](part/92.md)|
|93|1367|866122|15|[url](http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python)|[输出到stderr](part/93.md)|
|94|1363|1463625|11|[url](http://stackoverflow.com/questions/5226311/installing-specific-package-versions-with-pip)|[](part/94.md)|
|95|1361|1278391|28|[url](http://stackoverflow.com/questions/931092/reverse-a-string-in-python)|[反转字符串](part/95.md)|
|96|1355|893485|30|[url](http://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits)|[生成包含大写字母和数字的随机字符串](part/96.md)|
|97|1355|985061|16|[url](http://stackoverflow.com/questions/5082452/string-formatting-vs-format)|[字符串格式化:%和.format](part/97.md)|
|98|1334|979821|24|[url](http://stackoverflow.com/questions/541390/extracting-extension-from-filename-in-python)|[](part/98.md)|
|99|1334|1171947|26|[url](http://stackoverflow.com/questions/10660435/pythonic-way-to-create-a-long-multi-line-string)|[](part/99.md)|
|100|1321|677783|11|[url](http://stackoverflow.com/questions/1319615/proper-way-to-declare-custom-exceptions-in-modern-python)|[](part/100.md)|