两点水

This commit is contained in:
347073565@qq.com
2017-12-22 16:47:33 +08:00
parent 1b69364df2
commit f856b62e6f
14 changed files with 42 additions and 40 deletions

View File

@@ -24,7 +24,8 @@ print(list1[0:2])
输出的结果:
![访问 List列表中的值](https://user-gold-cdn.xitu.io/2017/6/21/eb8c85eb2cfccc112dbb891536014113)
![访问 List列表中的值](http://upload-images.jianshu.io/upload_images/2136918-ab562ada6ba08848?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 3、更新 List列表 ##
@@ -43,7 +44,7 @@ print(list1)
输出的结果:
![更新 List列表](https://user-gold-cdn.xitu.io/2017/6/21/286bf8a5953d10aada532eb3d2909921)
![更新 List列表](http://upload-images.jianshu.io/upload_images/2136918-96de950da2563ac6?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 4、删除 List列表 ##
@@ -60,7 +61,7 @@ print(list1)
输出的结果:
![删除 List列表](https://user-gold-cdn.xitu.io/2017/6/21/a2858b1cc9af6e02527119080a98b6a8)
![删除 List列表](http://upload-images.jianshu.io/upload_images/2136918-e761bf56f583089f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 5、List列表运算符 ##
@@ -154,4 +155,4 @@ print(newUser)
```
![list的使用](https://dn-mhke0kuv.qbox.me/529c1895edddaad61deb.png)
![list的使用](http://upload-images.jianshu.io/upload_images/2136918-65d31cae9f8bb34d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@@ -4,4 +4,4 @@
# 目录 #
![草根学Python List 和 Tuple](https://user-gold-cdn.xitu.io/2017/6/21/8135ae4d00e3ea07e3dae2df97fd9aaf)
![草根学Python List 和 Tuple](http://upload-images.jianshu.io/upload_images/2136918-4d3be05b7f048808?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

View File

@@ -25,9 +25,10 @@ tuple3=()
tuple4=(123,)
```
如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple又可以表示数学公式中的小括号这就产生了歧义因此Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值
如果不加逗号,创建出来的就不是 tuple (元组),而是指 ```123``` 这个数了,这是因为括号 ()既可以表示 tuple又可以表示数学公式中的小括号这就产生了歧义因此Python 规定,这种情况下,按小括号进行计算,计算结果自然是 ```123``` 。具体看下图 tuple4 和 tuple5 的输出值
![创建tuple](http://upload-images.jianshu.io/upload_images/2136918-2072470ffe7cbee7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![创建tuple](https://dn-mhke0kuv.qbox.me/f4b7a62091fb5d4f206f.png)
## 2、tuple元组的索引 ##
@@ -50,7 +51,7 @@ print(tuple2[0])
输出的结果:
![访问 tuple](https://dn-mhke0kuv.qbox.me/72844216bda8bc3e4a4b.png)
![访问 tuple](http://upload-images.jianshu.io/upload_images/2136918-edfb7c9ebc7d5ab0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
## 4、修改 tuple (元组) ##
@@ -114,4 +115,4 @@ del tuple1
|len(tuple)|计算元组元素个数|
|max(tuple)|返回元组中元素最大值|
|min(tuple)|返回元组中元素最小值|
|tuple(seq)|将列表转换为元组|
|tuple(seq)|将列表转换为元组|