Qhov txawv ntawm Python 2 thiab 3

Cov txheej txheem:

Qhov txawv ntawm Python 2 thiab 3
Qhov txawv ntawm Python 2 thiab 3

Video: Qhov txawv ntawm Python 2 thiab 3

Video: Qhov txawv ntawm Python 2 thiab 3
Video: Data Science with Python! Joining Tables Without a Common Column 2024, Lub Xya hli ntuj
Anonim

Qhov Tseem Ceeb Qhov txawv - Python 2 vs 3

Python yog ib hom lus programming siab. Nws yog multi-paradigm, uas yog Object-oriented nrog rau txheej txheem oriented. Python tau pom los ntawm Guido van Rossum. Nws yog ib hom lus programming yooj yim kawm thiab tuaj yeem siv rau ntau yam kev siv. Muaj ob lub ntsiab ntawm Python thiab lawv yog Python 2 thiab 3. Kab lus no tham txog qhov sib txawv ntawm ob lub versions no. Qhov sib txawv tseem ceeb ntawm Python 2 thiab 3 yog tias Python 2 yuav tau txais kev txhawb nqa yam tsawg kawg nkaus yav tom ntej thiab Python 3 yuav txuas ntxiv txhim kho ntxiv rau yav tom ntej.

Python 2 yog dab tsi?

Python yog ib hom lus nrov tshaj plaws rau kev ua haujlwm. Ntau lub tuam txhab siv Python lus rau kev txhim kho daim ntawv thov. Google, YouTube, Dropbox yog qee qhov ntawm lawv. Python muaj lub zej zog loj vim nws yooj yim kawm, nyeem thiab tswj. Nws txhawb cov txheej txheem-oriented programming nrog rau cov khoom-oriented programming.

Python siv tus neeg txhais lus los khiav qhov chaws. Tsis zoo li nyob rau hauv ib tug compiler raws li hom lus, Python neeg txhais lus tsis mus dhau tag nrho cov cai ib zaug. Hloov chaw, nws nyeem kab los ntawm kab thiab yog tias tus neeg txhais lus pom qhov yuam kev nws nres ua ntej ntxiv thiab muab lus yuam kev rau tus neeg siv. Python 2 tau nyob ib puag ncig ntev, yog li nws muaj ntau lub tsev qiv ntawv. Qhov nrov tshaj plaws ntawm Python 2 yog Python 2.7

Python 3 yog dab tsi?

Python 3 yog suav tias yog yav tom ntej ntawm Python. Nws yog tsim los ntxiv nta ntxiv thiab kho kab. Nws tseem tab tom tsim. Thaum pib, Python 2 tau nrov tab sis lub tswv yim ntawm Python 3 yog lub neej yav tom ntej ntawm cov lus, muab kev txhawb nqa rau Python 3 ib yam nkaus.

Qhov txawv ntawm Python 2 thiab 3
Qhov txawv ntawm Python 2 thiab 3

Daim duab 01: Python 3 Luam Ntawv Ua Haujlwm

Cov haujlwm ntawm Python 2 thiab 3 feem ntau zoo ib yam, muaj qhov sib txawv ntawm ob lub qauv no hauv syntax thiab tuav. Lub ntsiab kom zoo dua ntawm Python 3 yog qhov tshiab nta yuav txuas ntxiv mus rau cov lus.

Qhov Zoo sib xws ntawm Python 2 thiab 3 yog dab tsi?

  • Ob leeg yog cov qauv ntawm Python Language thiab lub hom phiaj dav dav.
  • Ob lub versions muaj rau qib siab programming lus qeb.
  • Ob leeg yog ntau lub ntsiab lus yog li, txhawb nqa Object-oriented programming thiab txheej txheem-oriented programming.
  • Ob leeg yog neeg txhais lus raws li hom lus.
  • Kev ua tiav qeeb piv rau cov lus sau ua ke.
  • Ob leeg muaj cov lus sib dhos uas yooj yim, thiab yog li ntawd, yooj yim sau, nyeem thiab tswj.
  • Ob leeg yooj yim rau kev debug cov kev pab cuam dua li lwm hom lus.
  • Ob qho tib si yog qhov pub dawb thiab qhib qhov chaw.
  • Ob leeg yog hla platformed, thiab muaj nyob rau ntau lub platform xws li Linux, Mac, Windows.
  • Python plhaub muab kev sib tham sib rau ob qho tib si Python 2 thiab 3.
  • Ob leeg muaj peev xwm cuam tshuam nrog ntau yam databases xws li MYSQL, Oracle, MSSQL, SQLite thiab lwm yam.
  • Ob leeg siv lub tshuab khib nyiab tsis siv neeg rau kev tswj hwm nco.
  • Ob leeg muaj peev xwm tsim Graphical User Interfaces (GUI).
  • Ob lub versions tsis tas yuav tshaj tawm hom kev sib txawv.
  • Ob leeg muaj cov pob khoom. e.g.- 'Numpy', 'Scipy' rau Scientific xam, 'Matplotlib' rau cov ntaub ntawv pom, 'Django', 'Flask' rau lub tsev websites.
  • Ob leeg tuaj yeem siv tau Multithreading.

Qhov txawv ntawm Python 2 thiab 3 yog dab tsi?

Python 2 vs Python 3

Python 2 yog ib hom lus ntawm Python programming lus uas yuav tau txais kev txhawb nqa yam tsawg kawg nkaus thiab ntxiv nta yav tom ntej. Python 3 yog ib hom lus ntawm Python programming lus uas txuas ntxiv ntxiv cov yam ntxwv tshiab thiab kab laum kho.
Sau Muaj nuj nqi
Hauv Python 2, nws tsis yog qhov yuav tsum tau siv kab lus. e.g. print “Hello World” Hauv Python 3, nws yog qhov yuav tsum tau siv kab lus. e.g. print (“Hello World”)
Nyob hauv Python 2, kev faib cov lej rov qab ua tus lej. 7/2 muab 3. Kom tau cov lus teb tseeb, tus programmer yuav tsum siv 7.0 / 2. 0. Nyob hauv Python 3, cov lej faib tuaj yeem muab cov lus teb ntab. 7/2 yuav muab 3.5.
Kev Txhawb Unicode
Txhawm rau ua txoj hlua Unicode hauv Python 2, yuav tsum siv tus cim 'u'. e.g. u “Hello” Hauv Python 3, txoj hlua yog Unicode los ntawm lub neej ntawd.
Raw_Input() Function
Nyob hauv Python 2, raw_input() muaj nuj nqi yog siv kom tau txais tswv yim los ntawm tus neeg siv. Txoj haujlwm no nyeem ib txoj hlua. Hauv Python 3, raw_input() muaj nuj nqi tsis muaj.
Input () Muaj nuj nqi
Nyob hauv Python 2, input() muaj nuj nqi tuaj yeem siv los nyeem ua cov hlua yog tias lawv nyob hauv cov ntawv sau lwm tus nyeem ua lej. Nyob hauv Python 3, input() muaj nuj nqi nyeem cov tswv yim ua ib txoj hlua.
Next() Function
Nyob hauv Python 2, lub tshuab hluav taws xob tom ntej () coj tus nqi tom ntej ntawm lub tshuab hluav taws xob. Nyob hauv Python 3, nws yog sau ua ntej (generator).
Third Party Module Txhawb nqa
Raws li Python 2 nyob ntawd ntev dua, muaj ntau tus neeg sab nrauv txhawb nqa. Qee lub hauv paus tseem siv Python 2. Python 3 tau txwv kev txhawb nqa thib peb-tog.

Summary – Python 2 vs 3

Python lus muaj ob hom. Qhov txawv ntawm Python 2 thiab 3 yog tias Python 2 yuav tau txais kev txhawb nqa yam tsawg kawg nkaus yav tom ntej thiab Python 3 yuav txuas ntxiv txhim kho yav tom ntej. Ob leeg muaj peev xwm zoo sib xws tab sis qee qhov ntawm lawv cov syntax txawv. Xijpeem lub version yog ob qho tib si siv rau kev tsim cov ntawv thov. Cov lus Python muaj txiaj ntsig zoo hauv thaj chaw xws li Cov Ntaub Ntawv Kev Tshawb Fawb, Kev Kawm Tshuab, Kev Ua Lus Ntuj, Kev Txhim Kho Hauv Web, Kev Tshawb Fawb, Kev Ua Duab, Robotics, Computer Vision thiab ntau ntxiv.

Download the PDF Version of Python 2 vs 3

Koj tuaj yeem rub tawm PDF version ntawm kab lus no thiab siv nws rau offline lub hom phiaj raws li daim ntawv ceeb toom. Thov download PDF version ntawm no Qhov txawv-Ntawm-Python-2-thiab-3

Pom zoo: