Python3 之訪問(wèn)元組【每日一個(gè)知識(shí)點(diǎn)第149期-Python】
訪問(wèn)元組
元組可以使用下標(biāo)索引來(lái)訪問(wèn)元組中的值,如下實(shí)例:
#!/usr/bin/Python3 tup1 = ('Google', 'Runoob', 1997, 2000) tup2 = (1, 2, 3, 4, 5, 6, 7 ) print ("tup1[0]: ", tup1[0]) print ("tup2[1:5]: ", tup2[1:5])
以上實(shí)例輸出結(jié)果:
tup1[0]: Google tup2[1:5]: (2, 3, 4, 5)
《Python入門(mén)每日一個(gè)知識(shí)點(diǎn)》欄目是馬哥教育Python年薪20萬(wàn)+的學(xué)員社群特別發(fā)起,分享Python工具、Python語(yǔ)法、Python項(xiàng)目等知識(shí)點(diǎn),幫助大家快速的了解Python學(xué)習(xí),快速步入Python高薪的快車道。
http://www.vfuj.cn/73198.html