日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

简明python教程五----数据结构(下)

發布時間:2024/1/8 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 简明python教程五----数据结构(下) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

引用

當你創建一個對象并給它賦一個變量的時候,這個變量僅僅引用那個對象,而不是表示這個對象本身!即,變量名指向你計算機中存儲那個對象的內存。

print 'Simple Assignment' shoplist = ['apple','mango','carrot','banana'] mylist = shoplistdel shoplist[0]print'shoplist is',shoplist print 'mylist is',mylistprint 'Copy by making a full slice' mylist = shoplist[:] del mylist[0]print 'shoplist is',shoplist print 'mylist is',mylist

結果:

Simple Assignment shoplist is ['mango', 'carrot', 'banana'] mylist is ['mango', 'carrot', 'banana'] Copy by making a full slice shoplist is ['mango', 'carrot', 'banana'] mylist is ['carrot', 'banana']

復制一個列表或者類似的序列或者其他復雜的對象(不是整數那樣 的簡單對象),那必須使用切片操作符來取得拷貝。

?

字符串

name='Swaroop' if name.startswith('Swar'):print 'Yes,the string starts with "Swar"' if 'a' in name:print 'Yes,it contains the string "a"' if name.find('war')!=-1:print 'Yes,it contains the string "war"'delimiter='_*_' mylist=['Brazil','Russia','India','China'] print delimiter.join(mylist)

結果:

Yes,the string starts with "Swar" Yes,it contains the string "a" Yes,it contains the string "war" Brazil_*_Russia_*_India_*_China

startswith():測試字符串是否以給定字符串開始,

in操作符:檢驗一個給定字符串是否為另一個字符串的一部分。

find:找出給定字符串在另一個字符串的位置,返回-1表示找不到字符串。

轉載于:https://www.cnblogs.com/Caden-liu8888/p/6386473.html

總結

以上是生活随笔為你收集整理的简明python教程五----数据结构(下)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。