Ziqhutywa njani iifayile ze.py

ziqhuba njani iifayile ze.py ngekhowudi yePython

Los iifayile ezinolwandiso lwe-.py ziqulathe ikhowudi yolwimi lwenkqubo yePython. Ngale ndlela xa uphumeza ifayile ulandelelwano lwekhowudi luyenziwa.

Ngokungafaniyo ne- .sh ifayile eyenza imiyalelo enokuthi nayiphi na inkqubo yeLinux iphumeze, ukwenzela ukuba ifayile ye.py isebenze kuya kufuneka uyihlohle iPython.

Le yinto yokuqala ekufuneka uyenzile ukuba ufuna ukuqala ukufunda ukwenza inkqubo ngePython.

Faka iPython kwaye ujonge uhlobo kwi-Ubuntu kunye neLinux

Ukuze wenze oku, kufuneka ube nendawo yePython elungiselelwe. KwiLinux unako

python --version

Ibuyisela inguqulelo yepython esiyifakileyo kwaye ukuba asinayo singayifaka. Sisebenzisa uguqulelo 3.x kwaye siyalibala malunga 2.7.x ephelelwe lixesha. Siza kufaka iPython 3 kwi-Ubuntu

sudo apt install python3

Iza kusibuza igama eligqithisiweyo lomsebenzisi omkhulu kwaye xa sele ifakiwe siya kujonga inguqulelo kwakhona ukuze siqiniseke ukuba yonke into ilungile.

python --version

Ngale nto sele ikho uyakwazi ukuqhuba iifayile. Vula i-console kwaye uye kwifolda apho i.py ikhona. Masithi sinefayile molo-world.py kwifolda yokuKhuphela

cd Descargas

Ngoku sikunika iimvume

chmod +x hello-world.py

Kwaye ekugqibeleni siyayifeza

./hello-world.py

Gcina ukhumbula ukuba ifayile ye-py ingenza into ibonakale, into yangaphakathi ongayiboniyo, okanye ibe lula imodyuli, oko kukuthi, ifayile enemisebenzi yePython, iinguqu, njl. isetyenziswe ngaphakathi ukwenza izikripthi kunye neenkqubo.

Phumeza okanye ufunde ifayile ngomzobo

Ukuba ufuna ukuyenza ngokucofa iqhosha. Kweli nqaku ndachaza indlela yokwenza. Yindlela yokushiya naluphi na ulwandiso olucwangcisiweyo ukuze xa ucofa kabini, likubuze ukuba uyafuna na ukuyiqhuba okanye ukhetha ukuvula ifayile ngesoftware oyikhethileyo. Icaciswe .sh kodwa iyafana kulo naluphi na ulwandiso.

Uyenza njani i.py

Ndithatha eli thuba ukucacisa indlela yokwenza ifayile ye.py

Ukubona ikhowudi ungasebenzisa umhleli wombhalo okanye i-IDE, eya kuba yinto efanelekileyo ukuba uzimisele ukufunda ukucwangcisa okanye ukuba ufuna ukuguqula ikhowudi. Okwangoku ndisebenzisa iGedit njengomhleli kunye nesicatshulwa kwaye njenge-IDE ndisebenzisa iKhowudi yeVisual Studio.

Indlela ekhawulezayo nge-terminal kukusebenzisa umyalelo wokuchukumisa

touch hello-world.py

Into entle malunga nokusebenzisa i-IDE efana ne-Visual Studio kukuba ungasebenzisa i-terminal kwi-IDE efanayo, ukuze kwangaxeshanye udale ifayile ungayinika iimvume, ukuyilungisa, njl. Konke oku ngaphandle kokubala inani lamathuba abasinika wona.

Shiya amazwana