大小:924.4M 语言: 中文
类型:游戏社交 系统:macOS





Python3.2.3官方文档(中文版)由笔者自己翻译学习Python2还是Python3?
罗振宇在今年的跨年演讲,《时间的朋友》中有个观点,大意是说,人们都有一种受虐情节,有时候希望别人对他粗暴一点。为此,他还举了两个例子,分别是“乔布斯对待消费者的态度”和“和菜头不尊重他的饮食需求”,末了还很享受的来一句:我爱死他了,对我再粗暴一点好不好!
看到很多新同学在学习Python的过程中,犹豫学习Python2还是学习Python3而迟迟不行动,白白地浪费了大把时间,错过了升职加薪的机会,我真心觉得非常遗憾。所以,我忍不住想对大家粗暴一次,给大家一个粗暴而又正确的答案:
应该学习Python2还是Python3?
都要学!
这个答案可能很出乎意料,也很容易反驳,例如:
Python3才是Python的未来
Python官方都建议指直接学习Python3
Python2只维护到2020年
真的是这样吗?作为一个在一线互联网公司奋斗的工程师,也是一个多年的Python老手,大家不妨来看看我这么说的理由。惠玩app1.1.4 安卓版
1)Python3取胜:
Now,in2018,it’smoreofano-brainer:Python3istheclearwinnerfornewlearnersorthosewantingtoupdatetudemheirskills.Here,we’llcoverwhyPython3isbetter,andwhycompanieshavebeenmovingfromPython2to3enmasse.
2)python2和3发展历史:
Python2.0wasfirstreleasedin2000.Itslatestversion,2.7,wasreleasedin2010.
Python3.0wasreleasedin2008.Itsnewestversion,3.6,wasreleasedin2016,andversion3.7iscurrentlyindevelopment.
AlthoughPython2.7isstillwidelyused,Python3adoptionisgrowingquickly.In2016,71.9%ofprojectsusedPython2.7,butby2017,ithadfallento63.7%.ThissignalsthattheprogrammingcommunityisturningtoPython3–albeitgradually–whendevelopingreal-worldapplications.
Notably,onJanuary1,2018,Python2.7will“retire”andnolongerbemaintained.(Theclockisliterallyticking!)
这个时间线很有意思。
3)python2和3的主要区别:
PYTHON2ISLEGACY,PYTHON3ISTHEFUTURE.因为python2即将被放弃维护。所以python2即将成为过去式(legacy)是显而易见的。
PYTHON2ANDPYTHON3HAVEDIFFERENT(SOMETIMESINCOMPATIBLE)LIBRARIES
二者支持的库不一样,而且转换起来也比较麻烦(complicated)
THEREISBETTERUNICODESUPPORTINPYTHON3
InPython3,textstringsareUnicodebydefault.InPython2,stringsarestoredasASCIIbydefault–youhavetoadda“u”ifyouwanttostorestringsasUnicodeinPython2.x.
ThisisimportantbecauseUnicodeismoreversatilethanASCII.Unicodestringscanstoreforeignlanguageletters,Romanlettersandnumerals,symbols,emojis,etc.,offeringyoumorechoices.
PYTHON3HASIMPROVEDINTEGERDIVISION:
InPython2,ifyouwriteanumberwithoutanydigitsafterthedecimalpoint,itroundsyourcalculationdowntothenearestwholenumber.
Forexample,ifyou’retryingtoperformthecalculation5dividedby2,andyoutype5/2,theresultwillbe2duetorounding.Youwouldhavetowriteitas5.0/2.0togettheexactanswerof2.5.
However,inPython3,theexpression5/2willreturntheexpectedresultof2.5withouthavingtoworryaboutaddingthoseextrazeroes.
ThisisoneexampleofhowPython3syntaxcanbemoreintuitive,makingiteasierfornewcomerstolearnPythonprogramming.
THETWOVERSIONSHAVEDIFFERENTPRINTSTATEMENTSYNTAXES
Thisisonlyasyntacticaldifference–andsomemayconsiderittrivial–soitdoesn’taffectthefunctionalityofPython.Thatsaid,itisstillabigandvisibledifferenceyoushouldknowabout.
Essentially,inPython3,theprintstatementhasbeenreplacedwithaprint()function.
4)为什么公司会选择从python2转到python3
Asmentionedearlier,mostcompaniesarestillusingPython2forlegacyreasons,butmoreandmorecompaniesareusingPython3,orbeginningtomaketheswitchfrom2to3.
So,let’slookatInstagramandFacebook–twocompaniesthathaveswitchedfromPython2to3orareintheprocessofdoingso–andwhytheychosetodoso.
目录
第一章Python初步介绍.
1.1Python用作计算器
1.1.1数字.
1.12字符串
1.1.3列表.
1.2初步走进编程之门.
第二章更多控制流程语句.
21if语句
2.2for语句
23range0方法.
2.4break和continue语句和在循环中的else子旬
2.5Pass语句.
2.6定义方法..
2.7更多关于方法定义
2.71默认参数值.
2.7.2关键字参数.
2.7.3可变参数列表
2.7.4拆分参数列表
2.7.5形式
2.7.6文档字符串
2.8编码风格.
第三章数据结构...
3.1列表
3.1.1把列表当做栈来用.
3.12把列表当做队列来用.
3.1.3递推式构造列表.
3.1.4嵌套列表推导式.
3.3元組和序列.
3.4Set集合.
2025/10/28 16:09/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 155 ) 盖楼(回复)
2025/11/06 21:57/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 35 ) 盖楼(回复)
2025/10/25 14:35/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 163 ) 盖楼(回复)
2025/10/24 03:37/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 137 ) 盖楼(回复)
2025/11/07 07:51/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 17 ) 盖楼(回复)
2025/10/22 12:15/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 54 ) 盖楼(回复)
2025/11/07 22:33/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 85 ) 盖楼(回复)
2025/10/28 07:32/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 152 ) 盖楼(回复)
2025/10/31 15:35/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 71 ) 盖楼(回复)
2025/10/25 20:19/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 20 ) 盖楼(回复)
2025/11/09 04:16/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 20 ) 盖楼(回复)
2025/11/06 16:12/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
">
支持( 148 ) 盖楼(回复)
/www/wwwroot/baoma/wp-admin/css/colors/red/template4.php on line 145
支持( 118 ) 盖楼(回复)
">