Dab tsi yog ntim hauv Python?
Dab tsi yog ntim hauv Python?

Video: Dab tsi yog ntim hauv Python?

Video: Dab tsi yog ntim hauv Python?
Video: nkauj huab lauj . koj tsis yuav kuv 2024, Hlis ntuj nqeg
Anonim

Ntim yog tej yam khoom uas tuav ib tug arbitrary naj npawb ntawm lwm yam khoom. Feem ntau, thawv muab ib txoj hauv kev nkag mus rau cov khoom uas muaj thiab rov hais dua lawv. Piv txwv ntawm thawv suav nrog tuple, list, set, dict; cov no yog cov built-in thawv . Thawv abstract base class (cov.

Kuj nug, Dab tsi yog Namedtuples hauv Python?

Sau npe hauv Python . Python txhawb nqa hom ntim xws li phau ntawv txhais lus hu ua " cov npe ()" tam sim no nyob rau hauv module, "sau". Zoo li phau ntawv txhais lus lawv muaj cov yuam sij uas hashed rau tus nqi tshwj xeeb. Tab sis ntawm qhov tsis sib xws, nws txhawb nqa ob qho tib si nkag los ntawm tus nqi tseem ceeb thiab iteration, lub functionality uas phau ntawv txhais lus tsis muaj.

Tom qab ntawd, lo lus nug yog, dab tsi yog hom ntaub ntawv hauv Python? Python txhawb nqa 4 hom ntaub ntawv tus lej.

  • int (kos npe tus lej zoo li 10, 2, 29, thiab lwm yam)
  • ntev (cov lej ntev siv rau ntau qhov ntau dua ntawm qhov tseem ceeb xws li 908090800L, -0x1929292L, thiab lwm yam)
  • ntab (float yog siv los khaws cov naj npawb ntab ntab xws li 1.9, 9.902, 15.2, thiab lwm yam)
  • complex (xws li 2.14j, 2.0 + 2.3j, thiab lwm yam)

Ntxiv mus, dab tsi yog python sau?

Kev sau hauv Python yog cov thawv uas siv los khaws cia kev sau ntawm cov ntaub ntawv, piv txwv li, npe, dict, teeb, tuple thiab lwm yam. Cov no yog built-in kev sau . Python collections module tau qhia los txhim kho cov haujlwm ntawm lub built-in sau thawv.

Daim ntawv teev npe hauv Python yog dab tsi?

A lis yog cov ntaub ntawv qauv hauv Python uas yog ib tug mutable, los yog hloov tau, txiav txim ib theem zuj zus. Txhua yam los yog tus nqi uas nyob hauv ib lis yog hu ua ib yam khoom. Ib yam li cov hlua tau txhais ua cov cim ntawm cov lus hais, cov npe yog txhais los ntawm qhov muaj nuj nqis ntawm square brackets.

Pom zoo: