Cov txheej txheem:
- Kauj ruam 1: Rub tawm Python
- Kauj Ruam 2: Txoj Haujlwm Tso Tawm, Sau Nqe Lus, thiab "Nyob Zoo Ntiaj Teb"
- Kauj ruam 3: Variables
- Kauj Ruam 4: Txoj Haujlwm Tawm Tswv Yim thiab Raw_input () Muaj nuj nqi
- Kauj ruam 5: Txuas ntxiv …
Video: Python Tutorial No.1: 5 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:30
Qhov no yog kev qhia Python ua nrog tus pib ua tiav hauv siab. Cov lus qhia luv rau Python yuav pab koj nkag siab txog keeb kwm thiab nws yog dab tsi, ua ntej peb txav mus rau cov lus qhia. Python yog dab tsi? Nqa los ntawm www.python.org:
Nab hab sej yog lub hom phiaj rau cov lus programming uas siv tau rau ntau yam kev txhim kho software. Nws muab kev txhawb nqa zoo rau kev koom ua ke nrog lwm yam lus thiab cov cuab yeej, los nrog cov txheej txheem cov tsev qiv ntawv, thiab tuaj yeem kawm tau ob peb hnub. Muaj ntau tus nab npawb programmer qhia txog kev tsim khoom tau zoo thiab xav tau cov lus txhawb kev txhim kho kom zoo dua qub, muaj cai tswj tau ntau dua. Hauv lwm lo lus, Python yog ib qho yooj yim kawm, nyeem, thiab sau, ua kom ntseeg tau tias koj yuav nkag siab qhov koj tau sau ob peb hlis tom qab koj sau nws. Keeb Kwm Keeb Kwm ntawm Python. Python tau xeeb tub thaum xyoo 1980 los ntawm Guido van Rossum hauv tebchaws Netherlands ua tus ua tiav ntawm ABC cov lus programming, thiab nws sai sai sau cov neeg nyiam, tshwj xeeb tshaj yog tom qab nws tau tshaj tawm hauv GPL hauv version 1.6.1. thiab thawj tus neeg siv BitTorrent. Nws kuj tseem siv tau ntau yam los ntawm Google thiab NASA. Note: Cov lus qhia no tau raug kho tshiab thiab txhim kho los ntawm nws tus kws sau (ZN13) thiab tus koom tes (Hugo. B) yog li thov ua siab ntev thiab mus ntsib, koj yuav pom kev kawm Python tau txais txiaj ntsig zoo. ZN13 Hugo. B
Kauj ruam 1: Rub tawm Python
Txhawm rau program hauv Python koj yuav tsum rub lub Python libraries, thiab Integrated DeveLopment Environment, IDLEAs ntawm 16/6/07, tso tawm yog version 2.5.1Python Rub tawm ntawm no. Peb yuav xav tias koj siv windows ntawm no, tab sis yog tias koj tab tom siv ib qho Linux-based OS, nws yuav zoo li twb tau teeb tsa lawm. Yog xav paub, qhib console/konsole/davhlau ya nyob twg (txawv nrog distro), thiab typepython. Yog tias nws tau teeb tsa, Python cov kab hais kom ua yuav qhib Tom qab koj tau teeb tsa nws, mus Pib> Txhua Qhov Kev Pabcuam> Python> IDLE thiab peb yuav pib!
Kauj Ruam 2: Txoj Haujlwm Tso Tawm, Sau Nqe Lus, thiab "Nyob Zoo Ntiaj Teb"
Ntawm no peb yuav qhia koj ib yam ntawm thawj yam yuav luag txhua tus programmer kawm: yuav ua li cas luam tawm "nyob zoo ntiaj teb". Nws yog tus programmer qhov ua piv txwv piv txwv thawj zaug. Nco tseg, luam ntawv tsis txhais hais tias luam ntawv zoo li hauv tus lej thiab ntawv, nws tsuas yog txhais tau tias tso saib, lossis tso tawm.
>> print "Nyob zoo ntiaj teb"Thiab koj yuav tau txais cov txiaj ntsig ntawm
Nyob Zoo Ntiaj TebN. B. Koj xav tau cov cim ("") los qhia rau Python tias koj xav kom nws luam tawm, tsis li ntawd koj yuav tau txais qhov no
>> luam tawm nyob zoo worldSyntaxError: syntax tsis raugnrog "ntiaj teb" yuav hais txog xim liab, los qhia qhov koj ua tsis raug.
Kauj ruam 3: Variables
Qhov sib txawv (mus rau qhov zoo tshaj plaws ntawm kuv qhov kev paub) yog qhov txuas rau lwm daim ntawv: Kuv yuav qhia: Ntaus qhov no rau hauv IDLE:
>> myvar = "Nyob Zoo Ntiaj Teb!" >>> & apos & apos & aposprint & apos & apos & apos & apos myvarHello World!myvar yog qhov sib txawv hauv qhov piv txwv no, tab sis kuj tseem tuaj yeem ua tus lej. siv nws los hloov cov ntawv/cov ntaub ntawv hauv txoj hlua
>> luam tawm " %s yog tus lej %d!" %("Python", 1) Python yog tus lej 1!"%s" txhais tau tias yog hloov txoj hlua thaum "%d" qhia tias yuav tsum tau hloov tus lej.
Kauj Ruam 4: Txoj Haujlwm Tawm Tswv Yim thiab Raw_input () Muaj nuj nqi
Txoj hauv kev yooj yim tshaj plaws kom tau txais cov neeg siv tswv yim los ntawm kab hais kom ua yog nrog
raw_input ()Nws nyeem los ntawm tus qauv nkag thiab muab cov hlua rau tus sib txawv uas koj xaiv. Piv txwv, qhov no yog qhov nws siv
name = raw_input ("Sau koj lub npe ntawm no:") hnub nyoog = raw_input ("Sau koj lub hnub nyoog ntawm no:") luam tawm "Koj lub npe yog:", nameprint "Thiab koj yog", hnub nyoogThaum Python tus neeg txhais lus nyeem thawj kab, nws yuav luam cov ntsiab lus hauv kab lus (Sau koj lub npe ntawm no:), thiab thaum koj nkag koj lub npe, nws yuav mus rau kab tom ntej, ua tib yam, tab sis thaum nws los hla qhov "luam tawm" nqe lus nws luam tawm cov ntsiab lus hauv kab lus, thiab los hla "lub npe" uas yog qhov sib txawv, ib txwm ua raws li txuas rau cov ntsiab lus koj tau nkag ua ntej, nrog cov txiaj ntsig hauv qab no
>> Nkag mus rau koj lub npe ntawm no: Hugo. BEnter your age here: 16Koj lub npe yog: Hugo. BAnd koj muaj 16 xyooNyob rau theem no, nws yuav yog lub tswv yim zoo los qhia rau tus txheej txheem ntawm kev tawm lus. Ua li feem ntau cov ntawv sau thiab lus Unix-plhaub, tus hash lossis phaus (#) kos npe qhia tias cov lus pom pib los ntawm # thiab txuas ntxiv mus txog thaum Qhov kawg ntawm kab ntawv. Nco tseg, hauv IDLE, thaum twg koj ntaus tus # cim, nws thiab txhua cov ntawv hauv qab no ntawm kab ntawd tig liab. Yog li
#Ceeb toom !!! Qhov no yuav ua rau CPU siv tau txog li 100% !!! counter = 0while counter <1000000: counter += 1 print counter
Kauj ruam 5: Txuas ntxiv …
Qhov chaw nyob ib ntus: Tos tos cov ntsiab lus tshiab, thov ua siab ntev. H. B.
Pom zoo:
Hloov-Hloov Cov Khoom Ua Si: Cov Khoom Ua Si Cov Khoom Ua Si Ua Tau Zoo!: 7 Cov Kauj Ruam (nrog Duab)
Hloov-Hloov Cov Khoom Ua Si: Cov Khoom Siv Hluav Taws Xob Ua Tau Zoo!: Qho khoom ua si hloov pauv qhib txoj hauv kev tshiab thiab kev daws teeb meem kom tso cai rau menyuam yaus uas muaj lub cev muaj peev xwm txwv lossis kev xiam oos qhab kev loj hlob los cuam tshuam nrog cov khoom ua si ntawm nws tus kheej. Hauv ntau qhov xwm txheej, cov menyuam yaus uas xav tau cov khoom ua si hloov pauv tsis tuaj yeem nkag mus
Cov av noo noo Cov Lus Qhia Tswj Xyuas Internet Txuas Cov Dej Dej (ESP32 thiab Blynk): 5 Cov Kauj Ruam
Cov av noo noo Cov lus pom zoo Tswj Xyuas Internet Txuas Cov Dej Dej (ESP32 thiab Blynk): Tsis txhawj xeeb txog koj lub vaj lossis nroj tsuag thaum koj mus rau hnub so ntev, lossis tsis nco qab ywg dej koj cov nroj tsuag txhua hnub. Zoo ntawm no yog kev daws teeb meem Nws cov av ya raws tswj hwm thiab thoob ntiaj teb txuas nrog cov dej txau dej tswj los ntawm ESP32 ntawm software pem hauv ntej kuv
Ua Cov Phiaj Xwm Zoo Los Ntawm Cov Ntaub Ntawv Nyob Arduino (thiab Txuag Cov Ntaub Ntawv rau Excel): 3 Cov Kauj Ruam
Ua Cov Phiaj Xwm Zoo Los Ntawm Cov Ntaub Ntawv Nyob Arduino (thiab Txuag Cov Ntaub Ntawv rau Excel): Peb txhua tus nyiam ua si nrog peb tus lej L … cov ntsiab lus tau ntxiv thiab nws tsis tshwj xeeb rau lub qhov muag. Arduino IDE cov phiaj xwm tsis
Cov Ntawv Cim Hluav Taws Xob LED Taws Teeb Cov Neeg Hlau Cov Ntawv Cim - Cov Khoom Siv Soldering: 11 Kauj Ruam
Cov Khoom Siv Hluav Taws Xob LED Taws Teeb Cov Neeg Hlau Daim Npav - Cov Khoom Siv Soldering: Kab lus no tau txaus siab txhawb nqa los ntawm PCBWAY.PCBWAY ua cov qauv zoo PCBs rau tib neeg thoob plaws ntiaj teb. Sim nws rau koj tus kheej thiab tau txais 10 PCBs rau tsuas yog $ 5 ntawm PCBWAY nrog qhov ua tau zoo heev, Ua tsaug PCBWAY. Robadge#1 uas kuv tau tsim rau
Raspberry Pi - PCA9536 Cov tswv yim/tso tawm Expander Python Tutorial: 4 Cov Kauj Ruam
Raspberry Pi-PCA9536 Cov tswv yim/tso tawm Expander Python Tutorial: PCA9536 yog 8-pin CMOS ntaus ntawv uas muab 4 khoom ntawm Lub Hom Phiaj Dav Dav Nkag Mus Los/Tso Tawm (GPIO) nthuav dav rau I2C-npav/SMBus daim ntawv thov. Nws suav nrog 4-ntsis Kev teeb tsa sau npe los ua haujlwm lub hom phiaj ntawm kev tawm tswv yim lossis xaiv tawm, 4-ntsis