av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)Python教程:python切片符號(hào)的使用

10年積累的網(wǎng)站制作、網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有蕭縣免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

a[start:stop]  # items start through stop-1
a[start:]      # items start through the rest of the array
a[:stop]       # items from the beginning through stop-1
a[:]           # a copy of the whole array

還有一個(gè)step值,可以與上述任何一個(gè)一起使用:

a[start:stop:step] # start through not past stop, by step

要記住的關(guān)鍵點(diǎn)是該:

1、stop值表示不在所選切片中的第一個(gè)值。之間的差stop和start是選擇的元素的數(shù)量(如果step是1,默認(rèn)值)。

2、startorstop可能是一個(gè)負(fù)數(shù),這意味著它從數(shù)組的末尾而不是開(kāi)頭開(kāi)始計(jì)數(shù)。

所以:

a[-1]    # last item in the array
a[-2:]   # last two items in the array
a[:-2]   # everything except the last two items

同樣,step可能是負(fù)數(shù):

a[::-1]    # all items in the array, reversed
a[1::-1]   # the first two items, reversed
a[:-3:-1]  # the last two items, reversed
a[-3::-1]  # everything except the last two items, reversed

如果項(xiàng)目少于您的要求,Python 對(duì)程序員是友好的。例如,如果你請(qǐng)求a[:-2]并且a只包含一個(gè)元素,你會(huì)得到一個(gè)空列表而不是錯(cuò)誤。有時(shí)您更喜歡錯(cuò)誤,因此您必須意識(shí)到這可能會(huì)發(fā)生。

以上就是python切片符號(hào)的使用,希望對(duì)大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程

本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。


分享文章:創(chuàng)新互聯(lián)Python教程:python切片符號(hào)的使用
文章轉(zhuǎn)載:http://uogjgqi.cn/article/dheghoc.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流