|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
>>> print('元组,戴上了枷锁的列表')
元组,戴上了枷锁的列表
>>> print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>>> tuple1=(1,2,3,4,5,7,6)
>>> tuple1[1]
2
>>> tuple1[5:]
(7, 6)
>>> tuple1[:]
(1, 2, 3, 4, 5, 7, 6)
>>> tuple1[0]=9
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
tuple1[0]=9
TypeError: 'tuple' object does not support item assignment
>>> temp=(1)
>>> temp
1
>>> type(temp)
<class 'int'>
>>> type(tuple1)
<class 'tuple'>
>>> temp2=1,2,3,4,
>>> type(temp2)
<class 'tuple'>
>>> temp=(1,)
>>> type(temp)
<class 'tuple'>
>>> temp3=2,4,2,3,4
>>> type(temp3)
<class 'tuple'>
>>> print('元组中,逗号是关键')
元组中,逗号是关键
>>> 3*5
15
>>> 3*5,
(15,)
>>> 3*(5)
15
>>> 3*(5,)
(5, 5, 5)
>>> temp=('小甲鱼','黑夜','迷途')
>>> temp.insert(2.'怡静')
SyntaxError: invalid syntax
>>> temp.insert(2,'怡静')
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
temp.insert(2,'怡静')
AttributeError: 'tuple' object has no attribute 'insert'
>>> print('哪些操作符可以用在元组上,')
哪些操作符可以用在元组上,
>>> |
|