Skip to content

Commit 238d6f7

Browse files
committed
理解元祖
1 parent 447c760 commit 238d6f7

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,29 @@ strace -p [pid] -tt -s 1024 -o /tmp/[pid].log
12201220
```
12211221

12221222

1223+
## 理解 tuple (元祖)
1224+
1225+
为什么当tuple只有一个item时,需要加逗号
1226+
1227+
```
1228+
In [1]: (3+4)*5
1229+
Out[1]: 35
1230+
1231+
In [2]: (3+4,)*5
1232+
Out[2]: (7, 7, 7, 7, 7)
1233+
```
1234+
1235+
```
1236+
In [3]: type(('fuck'))
1237+
Out[3]: str
1238+
1239+
In [4]: type(('fuck',))
1240+
Out[4]: tuple
1241+
```
1242+
1243+
Not the parentheses make the tuple, the commas do.
1244+
1245+
12231246
## 文档托管
12241247

12251248
Read the Docs

0 commit comments

Comments
 (0)