Home

Awesome

stackoverflow-py-top-qa

Notice:

目前进度90%, 剩余40+个问题实在没时间翻了, 有兴趣的同学可以试试, 提pr. or后续我找时间处理完整.

stackoverflow上Python相关回答整理翻译(相对来说都比较简单/散,非系统学习用途,个人整理而已)

当前进度: 90%
问题个数: 135
最后更新: 2014-10-04

查看了下前面(vote前15页,挑了下,vote都是100+的样子,大概200个)的问题,链接

第一页的前几个比较长,目测都有中文翻译版本,大家可以网上搜下

如果有兴趣,可以一起翻译

注意,合并了每个问题的多个答案,但是时间仓促,疏漏难免,感兴趣问题直接点链接看原文吧

目录

基础

基本数据结构

进阶

其他

待翻译问题链接(还剩0问题)

qa-tuple.md:问题 (http://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python)

已翻译问题链接(去重)

qa-built-in.md:问题 (http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print)

qa-built-in.md:问题 (http://stackoverflow.com/questions/1835018/python-check-if-an-object-is-a-list-or-tuple-but-not-string)

qa-built-in.md:问题 (http://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python)

qa-built-in.md:问题 (http://stackoverflow.com/questions/402504/how-to-determine-the-variable-type-in-python)

qa-built-in.md:问题 (http://stackoverflow.com/questions/675442/comment-out-a-python-code-block)

qa-built-in.md:问题 (http://stackoverflow.com/questions/397148/why-doesnt-python-have-multiline-comments)

qa-built-in.md:问题 (http://stackoverflow.com/questions/56011/single-quotes-vs-double-quotes-in-python)

qa-built-in.md:问题 (http://stackoverflow.com/questions/13857/can-you-explain-closures-as-they-relate-to-python)

qa-built-in.md:问题 (http://stackoverflow.com/questions/890128/python-lambda-why)

qa-built-in.md:问题 (http://stackoverflow.com/questions/1436703/difference-between-str-and-repr-in-python)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/73663/terminating-a-python-script)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/26595/is-there-any-difference-between-foo-is-none-and-foo-none)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/522563/accessing-the-index-in-python-for-loops)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/53162/how-can-i-do-a-line-break-line-continuation-in-python)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/9284350/why-does-1-in-1-0-true-evaluate-to-false)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/2710940/python-if-x-is-not-none-or-if-not-x-is-none)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/843277/how-do-i-check-if-a-variable-exists-in-python)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/743164/do-while-loop-in-python)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/135041/should-you-always-favor-xrange-over-range)

qa-control-flow.md:问题 (http://stackoverflow.com/questions/15376509/when-is-i-x-different-from-i-i-x-in-python)

qa-datetime.md:问题 (http://stackoverflow.com/questions/1697815/how-do-you-convert-a-python-time-struct-time-object-into-a-datetime-object)

qa-datetime.md:问题 (http://stackoverflow.com/questions/415511/how-to-get-current-time-in-python)

qa-datetime.md:问题 (http://stackoverflow.com/questions/85451/python-time-clock-vs-time-time-accuracy)

qa-datetime.md:问题 (JSON datetime between Python and JavaScript)

qa-dict.md:问题 (http://stackoverflow.com/questions/1747817/python-create-a-dictionary-with-list-comprehension)

qa-dict.md:问题 (http://stackoverflow.com/questions/1323410/has-key-or-in)

qa-dict.md:问题 (http://stackoverflow.com/questions/1602934/check-if-a-given-key-already-exists-in-a-dictionary)

qa-dict.md:问题 (http://stackoverflow.com/questions/1024847/add-to-a-dictionary-in-python)

qa-dict.md:问题 (http://stackoverflow.com/questions/1305532/convert-python-dict-to-object)

qa-dict.md:问题 (http://stackoverflow.com/questions/38987/how-can-i-merge-union-two-python-dictionaries-in-a-single-expression)

qa-dict.md:问题 (http://stackoverflow.com/questions/209840/map-two-lists-into-a-dictionary-in-python)

qa-dict.md:问题 (http://stackoverflow.com/questions/72899/in-python-how-do-i-sort-a-list-of-dictionaries-by-values-of-the-dictionary)

qa-dict.md:问题 (http://stackoverflow.com/questions/613183/python-sort-a-dictionary-by-value)

qa-dict.md:问题 (http://stackoverflow.com/questions/4901815/object-as-a-dictionary-key)

qa-exception.md:问题 (http://stackoverflow.com/questions/1319615/proper-way-to-declare-custom-exceptions-in-modern-python)

qa-exception.md:问题 (http://stackoverflow.com/questions/2052390/how-do-i-manually-throw-raise-an-exception-in-python)

qa-exception.md:问题 (http://stackoverflow.com/questions/6470428/catch-multiple-exceptions-in-one-line-except-block)

qa-exception.md:问题 (http://stackoverflow.com/questions/944592/best-practice-for-python-assert)

qa-exception.md:问题 (http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python)

qa-exception.md:问题 (http://stackoverflow.com/questions/944592/best-practice-for-python-assert)

qa-file.md:问题 (http://stackoverflow.com/questions/82831/how-do-i-check-if-a-file-exists-using-python)

qa-file.md:问题 (http://stackoverflow.com/questions/273192/python-best-way-to-create-directory-if-it-doesnt-exist-for-file-write)

qa-file.md:问题 (http://stackoverflow.com/questions/123198/how-do-i-copy-a-file-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/275018/how-can-i-remove-chomp-a-newline-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/237079/how-to-get-file-creation-modification-date-times-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/466345/converting-string-into-datetime)

qa-file.md:问题 (http://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory)

qa-file.md:问题 (http://stackoverflow.com/questions/3964681/find-all-files-in-directory-with-extension-txt-with-python)

qa-file.md:问题 (http://stackoverflow.com/questions/3277503/python-read-file-line-by-line-into-array)

qa-file.md:问题 (http://stackoverflow.com/questions/4706499/how-do-you-append-to-file-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/541390/extracting-extension-from-filename-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/3207219/how-to-list-all-files-of-a-directory-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/1450393/how-do-you-read-from-stdin-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/845058/how-to-get-line-count-cheaply-in-python)

qa-file.md:问题 (http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python)

qa-func.md:问题 (http://stackoverflow.com/questions/251464/how-to-get-the-function-name-as-string-in-python)

qa-func.md:问题 (http://stackoverflow.com/questions/3061/calling-a-function-from-a-string-with-the-functions-name-in-python)

qa-func.md:问题 (http://stackoverflow.com/questions/36901/what-does-double-star-and-star-do-for-python-parameters)

qa-func.md:问题 (http://stackoverflow.com/questions/1098549/proper-way-to-use-kwargs-in-python)

qa-func.md:问题 (http://stackoverflow.com/questions/3394835/args-and-kwargs)

qa-func.md:问题 (http://stackoverflow.com/questions/682504/what-is-a-clean-pythonic-way-to-have-multiple-constructors-in-python)

qa-func.md:问题 (http://stackoverflow.com/questions/36901/what-does-double-star-and-star-do-for-python-parameters)

qa-func.md:问题 (http://stackoverflow.com/questions/11241523/why-does-python-code-run-faster-in-a-function)

qa-func.md:问题 (http://stackoverflow.com/questions/986006/how-do-i-pass-a-variable-by-reference)

qa-list.md:问题 (http://stackoverflow.com/questions/509211/the-python-slice-notation)

qa-list.md:问题 (http://stackoverflow.com/questions/53513/python-what-is-the-best-way-to-check-if-a-list-is-empty)

qa-list.md:问题 (http://stackoverflow.com/questions/1720421/merge-two-lists-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/518021/getting-the-length-of-an-array-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/2612802/how-to-clone-a-list-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/252703/python-append-vs-extend)

qa-list.md:问题 (http://stackoverflow.com/questions/306400/how-do-i-randomly-select-an-item-from-a-list-using-python)

qa-list.md:问题 (http://stackoverflow.com/questions/627435/how-to-remove-an-element-from-a-list-by-index-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/930397/how-to-get-the-last-element-of-a-list)

qa-list.md:问题 (http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order)

qa-list.md:问题 (http://stackoverflow.com/questions/1207406/remove-items-from-a-list-while-iterating-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/176918/in-python-how-do-i-find-the-index-of-an-item-given-a-list-containing-it)

qa-list.md:问题 (http://stackoverflow.com/questions/952914/making-a-flat-list-out-of-list-of-lists-in-python)

qa-list.md:问题 (http://stackoverflow.com/questions/1247486/python-list-comprehension-vs-map)

qa-list.md:问题 (http://stackoverflow.com/questions/626759/whats-the-difference-between-list-and-tuples)

qa-list.md:问题 (http://stackoverflow.com/questions/17160162/what-is-in-python-2-7)

qa-math.md:问题 (http://stackoverflow.com/questions/1476/how-do-you-express-binary-literals-in-python)

qa-math.md:问题 (http://stackoverflow.com/questions/209513/convert-hex-string-to-int-in-python)

qa-math.md:问题 (http://stackoverflow.com/questions/1267869/how-can-i-force-division-to-be-floating-point-in-python)

qa-math.md:问题 (http://stackoverflow.com/questions/961632/converting-integer-to-string-in-python)

qa-math.md:问题 (http://stackoverflow.com/questions/306313/python-is-operator-behaves-unexpectedly-with-integers)

qa-math.md:问题 (http://stackoverflow.com/questions/455612/limiting-floats-to-two-decimal-points)

qa-math.md:问题 (http://stackoverflow.com/questions/432842/how-do-you-get-the-logical-xor-of-two-variables-in-python)

qa-math.md:问题 (http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python)

qa-math.md:问题 (http://stackoverflow.com/questions/1485841/behaviour-of-increment-and-decrement-operators-in-python)

qa-modules.md:问题 (http://stackoverflow.com/questions/448271/what-is-init-py-for)

qa-modules.md:问题 (http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path)

qa-modules.md:问题 (http://stackoverflow.com/questions/247770/retrieving-python-module-path)

qa-modules.md:问题 (http://stackoverflow.com/questions/44834/can-someone-explain-all-in-python)

qa-modules.md:问题 (http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module)

qa-modules.md:问题 (http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python)

qa-modules.md:问题 (http://stackoverflow.com/questions/419163/what-does-if-name-main-do)

qa-modules.md:问题 (http://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path)

qa-modules.md:问题 (http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/2709821/python-self-explained)

qa-oop.md:问题 (http://stackoverflow.com/questions/70528/why-are-pythons-private-methods-not-actually-private)

qa-oop.md:问题 (http://stackoverflow.com/questions/38238/what-are-class-methods-in-python-for)

qa-oop.md:问题 (http://stackoverflow.com/questions/674304/pythons-use-of-new-and-init)

qa-oop.md:问题 (http://stackoverflow.com/questions/510972/getting-the-class-name-of-an-instance-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/136097/what-is-the-difference-between-staticmethod-and-classmethod-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/735975/static-methods-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/68645/static-class-variables-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/610883/how-to-know-if-an-object-has-an-attribute-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/31875/is-there-a-simple-elegant-way-to-define-singletons-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/576169/understanding-python-super-and-init-methods)

qa-oop.md:问题 (http://stackoverflow.com/questions/1952464/in-python-how-do-i-determine-if-an-object-is-iterable)

qa-oop.md:问题 (http://stackoverflow.com/questions/19151/build-a-basic-python-iterator)

qa-oop.md:问题 (http://stackoverflow.com/questions/372042/difference-between-abstract-class-and-interface-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/472000/python-slots)

qa-oop.md:问题 (http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/6618002/python-property-versus-getters-and-setters)

qa-oop.md:问题 (http://stackoverflow.com/questions/904036/chain-calling-parent-constructors-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/1301346/the-meaning-of-a-single-and-a-double-underscore-before-an-object-name-in-python)

qa-oop.md:问题 (http://stackoverflow.com/questions/972/adding-a-method-to-an-existing-object)

qa-oop.md:问题 (http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python/6581949#6581949)

qa-oop.md:问题 (http://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument)

qa-others.md:问题 (http://stackoverflow.com/questions/170921/should-i-learn-python-2-before-3-or-start-directly-from-python-3)

qa-others.md:问题 (http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv)

qa-others.md:问题 (http://stackoverflow.com/questions/990754/how-to-leave-a-python-virtualenv)

qa-others.md:问题 (http://stackoverflow.com/questions/193161/what-is-the-best-project-structure-for-a-python-application)

qa-others.md:问题 (http://stackoverflow.com/questions/13311094/counter-in-collections-module-python)

qa-others.md:问题 (http://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python)

qa-others.md:问题 (http://stackoverflow.com/questions/4941145/python-flask-vs-bottle)

qa-others.md:问题 (http://stackoverflow.com/questions/582336/how-can-you-profile-a-python-script)

qa-others.md:问题 (http://stackoverflow.com/questions/2775864/python-create-unix-timestamp-five-minutes-in-the-future)

qa-others.md:问题 (http://stackoverflow.com/questions/89228/calling-an-external-command-in-python)

qa-others.md:问题 (http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python)

qa-others.md:问题 (http://stackoverflow.com/questions/261638/how-do-i-protect-python-code)

qa-others.md:问题 (http://stackoverflow.com/questions/191673/preferred-python-unit-testing-framework)

qa-others.md:问题 (http://stackoverflow.com/questions/61151/where-do-the-python-unit-tests-go)

qa-others.md:问题 (http://stackoverflow.com/questions/6344076/differences-between-distribute-distutils-setuptools-and-distutils2)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/1231688/how-do-i-remove-packages-installed-with-pythons-easy-install)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/1550226/python-setup-py-uninstall)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/739993/get-a-list-of-installed-python-modules)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/3220404/why-use-pip-over-easy-install)

qa-pip-easy_install.md:问题 (http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/712791/json-and-simplejson-module-differences-in-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/4480075/argparse-optional-positional-arguments)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/842059/is-there-a-portable-way-to-get-the-current-username-in-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/1912434/how-do-i-parse-xml-in-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/534839/how-to-create-a-guid-in-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/2018026/should-i-use-urllib-or-urllib2-or-requests)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/192109/is-there-a-function-in-python-to-print-all-the-current-properties-and-values-of)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/132058/showing-the-stack-trace-from-a-running-python-application)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/1549801/differences-between-isinstance-and-type-in-python)

qa-std-modules.md:问题 (http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python)

qa-string.md:问题 (http://stackoverflow.com/questions/493819/python-join-why-is-it-string-joinlist-instead-of-list-joinstring)

qa-string.md:问题 (http://stackoverflow.com/questions/6797984/how-to-convert-string-to-lowercase-in-python)

qa-string.md:问题 (http://stackoverflow.com/questions/931092/reverse-a-string-in-python)

qa-string.md:问题 (http://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-method)

qa-string.md:问题 (http://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-in-python)

qa-string.md:问题 (http://stackoverflow.com/questions/5082452/python-string-formatting-vs-format)

qa-string.md:问题 (http://stackoverflow.com/questions/988228/converting-a-string-to-dictionary)

qa-string.md:问题 (http://stackoverflow.com/questions/227459/ascii-value-of-a-character-in-python)

qa-string.md:问题 (http://stackoverflow.com/questions/1059559/python-strings-split-with-multiple-separators)

qa-string.md:问题 (http://stackoverflow.com/questions/1185524/how-to-trim-whitespace-including-tabs)

qa-string.md:问题 (http://stackoverflow.com/questions/663171/is-there-a-way-to-substring-a-string-in-python)

qa-string.md:问题 (http://stackoverflow.com/questions/1504717/python-vs-is-comparing-strings-is-fails-sometimes-why)

qa-string.md:问题 (http://stackoverflow.com/questions/339007/python-nicest-way-to-pad-zeroes-to-string)

qa-string.md:问题 (http://stackoverflow.com/questions/606191/convert-byte-array-to-python-string)

contributors

thx a lot:)

more link

Donation

You can Buy me a coffee:) link


To Be Continue ...

wklken

Email: wklken@yeah.net

Blog: http://wklken.me

2013-09-21 于深圳