Muaj pes tsawg tus yuam sij zoo ib yam tuaj yeem muaj phau ntawv txhais lus muaj Python?
Muaj pes tsawg tus yuam sij zoo ib yam tuaj yeem muaj phau ntawv txhais lus muaj Python?

Video: Muaj pes tsawg tus yuam sij zoo ib yam tuaj yeem muaj phau ntawv txhais lus muaj Python?

Video: Muaj pes tsawg tus yuam sij zoo ib yam tuaj yeem muaj phau ntawv txhais lus muaj Python?
Video: Mathematics with Python! Sequences 2024, Kaum ib hlis
Anonim

Cov tus yuam sij qhia lub ntsiab ntawm lub phau ntawv txhais lus , tus nqi yog cov ntaub ntawv sib raug rau qhov muab tus yuam sij . Ntsiab tus nqi yog tshwj xeeb, i. e. nyob ntawd ua tau tsis yog ob cov yuam sij zoo ib yam hauv phau ntawv txhais lus.

Ntxiv mus, phau ntawv txhais lus puas tuaj yeem muaj tus yuam sij Python?

Python phau ntawv txhais lus tsis txhawb yuam sij dua . Ib txoj hauv kev yog khaws cov npe lossis teeb tsa hauv lub phau ntawv txhais lus . thiab koj yuav tau txais ib phau ntawv txhais lus ntawm cov npe.

Kuj Paub, ua li cas koj iterate tshaj phau ntawv txhais lus hauv python? Muaj ob txoj hauv kev iterating los ntawm a Python phau ntawv txhais lus khoom. Ib qho yog txhawm rau nqa tus nqi cuam tshuam rau txhua tus yuam sij hauv keys() daim ntawv teev npe. Tseem muaj cov khoom () txoj kev ntawm phau ntawv txhais lus khoom uas xa rov qab cov npe ntawm tuples, txhua tuple muaj qhov tseem ceeb thiab tus nqi.

Yog li ntawd, koj yuav ua li cas xyuas seb tus yuam sij yog nyob rau hauv phau ntawv txhais lus python?

Kom yooj yim xyuas seb puas muaj tus yuam sij muaj nyob rau hauv ib Python phau ntawv txhais lus koj tuaj yeem siv tus neeg teb xov tooj los tshawb nrhiav los ntawm cov phau ntawv txhais lus zoo li no: tsiaj = {'cats': 1, 'dub': 2, 'ntses': 3} yog ' dev' hauv tsiaj: luam tawm ('Dog pom!') # dev pom!

Python phau ntawv txhais lus puas muaj ntau yam txiaj ntsig?

Hauv python , a phau ntawv txhais lus tau tsuas tuav ib leeg xwb tus nqi rau tus yuam sij muab. Txawm li cas los xij, yog tias koj siv hom ntaub ntawv muaj feem rau qhov ntawd tus nqi , koj yuav tsum tau txuag ntau tus nqi rau ib tus yuam sij. Kev xaiv 1: Siv ib tug tuple los sawv cev tus nqi ntawm tus yuam sij.

Pom zoo: