>>>#变量引用str >>> s = "abc" >>> s 'abc' >>>#如果这样写,就会是... >>> t = 123,'abc',["come","here"] >>> t (123, 'abc', ['come', 'here'])
>>> t = 1,"23",[123,"abc"],("python","learn") #元素多样性,近list
>>> t
(1, '23', [123, 'abc'], ('python', 'learn'))
>>> t[0] = 8 #不能原地修改,近str
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> t.append("no")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'append'
>>>
>>> one_list = ["python","qiwsir","github","io"] >>> one_list[2] 'github' >>> one_list[1:] ['qiwsir', 'github', 'io'] >>> for word in one_list: ... print word ... python qiwsir github io >>> len(one_list) 4
>>> t
(1, '23', [123, 'abc'], ('python', 'learn'))
>>> t[2]
[123, 'abc']
>>> t[1:]
('23', [123, 'abc'], ('python', 'learn'))
>>> for every in t:
... print every
...
1
23
[123, 'abc']
('python', 'learn')
>>> len(t)
4
>>> t[2][0] #还能这样呀,哦对了,list中也能这样
123
>>> t[3][1]
'learn'
>>> t
(1, '23', [123, 'abc'], ('python', 'learn'))
>>> tls = list(t) #tuple-->list
>>> tls
[1, '23', [123, 'abc'], ('python', 'learn')]
>>> t_tuple = tuple(tls) #list-->tuple
>>> t_tuple
(1, '23', [123, 'abc'], ('python', 'learn'))
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有