本文簡介的是Python列表,在電腦語言中,Python列表是被廣泛應用的語言,如果你有一些關於Python列表的實際相關應用的技巧有不解之處時,你可以瀏覽我們的文章,以下是文章的內容簡介。
Python中沒有數組的資料結構,但列表很像數組,如:
a=[0,1,2]这时a[0]=0, a[1]=1, a[[2]=2,
但引出一個問題,即如果數組a想定義為0到999怎麼辦,這時可能透過a = range(0, 1000 )實現。或省略為a = range(1000).如果想定義1000長度的a,初始值全為0,則
a = [0 for x in range(0, 1000)]
這裡定義了10*10初始為0的二維數組。後來,我在網路上找到了更簡單的字義二維數組的方法:b = [[0]*10]*10,定義10*10初始為0的二維數組。與
a=[[0 for x in range(10)] for y in range(10)]
比較:print a==b的結果為True。但用b的定義方法代替a後,以前的可以正常運作的程式也出錯了,經過仔細分析得出區別:a[0][0]=1時,只有a[0][0]為1,其他全為0。 b[0][0]=1時,a[0][0],a[1][0],只到a[9,0]全部為1。由此得到大數組中的10個小的一維資料全是一個相同的引用,即指向同一位址。故 b = [[0]*10]*10並不符合我們常規意義上的二維數組。
同時經過試驗:c=[0]*10的定義與c=[0 for x in range(10)]有相同的效果,而沒有上面相同引用的問題,估計數組c的定義時是值類型相乘,而前面b的用類型的相乘,因為一維數組是一個引用(借用C#中的值類型和引用類型,不知是否合適)。 以上文章就是Python列表的部分介紹。
以上就是Python列表中的陣列如何引用的內容,更多相關文章請關注PHP中文網(www.php.cn)!

pythonisehybridmodeLofCompilation和interpretation:1)thepythoninterpretercompilesourcecececodeintoplatform- interpententbybytecode.2)thepythonvirtualmachine(pvm)thenexecutecutestestestestestesthisbytecode,ballancingEaseofuseEfuseWithPerformance。

pythonisbothinterpretedAndCompiled.1)它的compiledTobyTecodeForportabilityAcrosplatforms.2)bytecodeisthenInterpreted,允許fordingfordforderynamictynamictymictymictymictyandrapiddefupment,儘管Ititmaybeslowerthananeflowerthanancompiledcompiledlanguages。

在您的知識之際,而foroopsareideal insinAdvance中,而WhileLoopSareBetterForsituations則youneedtoloopuntilaconditionismet

ForboopSareSusedwhenthentheneMberofiterationsiskNownInAdvance,而WhileLoopSareSareDestrationsDepportonAcondition.1)ForloopSareIdealForiteratingOverSequencesLikelistSorarrays.2)whileLeleLooleSuitableApeableableableableableableforscenarioscenarioswhereTheLeTheLeTheLeTeLoopContinusunuesuntilaspecificiccificcificCondond

pythonisnotpuroly interpred; itosisehybridablectofbytecodecompilationandruntimeinterpretation.1)PythonCompiLessourceceCeceDintobyTecode,whitsthenexecececected bytybytybythepythepythepythonvirtirtualmachine(pvm).2)

concatenateListSinpythonWithTheSamelements,使用:1)operatoTotakeEpduplicates,2)asettoremavelemavphicates,or3)listcompreanspherensionforcontroloverduplicates,每個methodhasdhasdifferentperferentperferentperforentperforentperforentperfornceandordorimplications。

pythonisanterpretedlanguage,offeringosofuseandflexibilitybutfacingperformancelanceLimitationsInCricapplications.1)drightingedlanguageslikeLikeLikeLikeLikeLikeLikeLikeThonexecuteline-by-line,允許ImmediaMediaMediaMediaMediaMediateFeedBackAndBackAndRapidPrototypiD.2)compiledLanguagesLanguagesLagagesLikagesLikec/c thresst

Useforloopswhenthenumberofiterationsisknowninadvance,andwhileloopswheniterationsdependonacondition.1)Forloopsareidealforsequenceslikelistsorranges.2)Whileloopssuitscenarioswheretheloopcontinuesuntilaspecificconditionismet,usefulforuserinputsoralgorit


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

WebStorm Mac版
好用的JavaScript開發工具

SublimeText3漢化版
中文版,非常好用

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具