mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-27 12:03:29 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
t = (10, 11, 12, 13, 14)
|
||||
t
|
||||
|
||||
@@ -14,7 +14,7 @@ t
|
||||
|
||||
Out[1]:
|
||||
|
||||
```
|
||||
```py
|
||||
(10, 11, 12, 13, 14)
|
||||
```
|
||||
|
||||
@@ -22,27 +22,27 @@ Out[1]:
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
t[0]
|
||||
|
||||
```
|
||||
|
||||
Out[2]:
|
||||
|
||||
```
|
||||
```py
|
||||
10
|
||||
```
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
t[1:3]
|
||||
|
||||
```
|
||||
|
||||
Out[3]:
|
||||
|
||||
```
|
||||
```py
|
||||
(11, 12)
|
||||
```
|
||||
|
||||
@@ -50,13 +50,13 @@ Out[3]:
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
# 会报错
|
||||
t[0] = 1
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
---------------------------------------------------------------------------
|
||||
TypeError Traceback (most recent call last)
|
||||
<ipython-input-4-da6c1cabf0b0> in <module>()
|
||||
@@ -72,14 +72,14 @@ TypeError: 'tuple' object does not support item assignment
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
a = (10,)
|
||||
print a
|
||||
print type(a)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
(10,)
|
||||
<type 'tuple'>
|
||||
|
||||
@@ -87,13 +87,13 @@ print type(a)
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
a = (10)
|
||||
print type(a)
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
<type 'int'>
|
||||
|
||||
```
|
||||
@@ -102,7 +102,7 @@ print type(a)
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
a = [10, 11, 12, 13, 14]
|
||||
tuple(a)
|
||||
|
||||
@@ -110,7 +110,7 @@ tuple(a)
|
||||
|
||||
Out[7]:
|
||||
|
||||
```
|
||||
```py
|
||||
(10, 11, 12, 13, 14)
|
||||
```
|
||||
|
||||
@@ -120,27 +120,27 @@ Out[7]:
|
||||
|
||||
In [8]:
|
||||
|
||||
```
|
||||
```py
|
||||
a.count(10)
|
||||
|
||||
```
|
||||
|
||||
Out[8]:
|
||||
|
||||
```
|
||||
```py
|
||||
1
|
||||
```
|
||||
|
||||
In [9]:
|
||||
|
||||
```
|
||||
```py
|
||||
a.index(12)
|
||||
|
||||
```
|
||||
|
||||
Out[9]:
|
||||
|
||||
```
|
||||
```py
|
||||
2
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user