# 元组只有两个方法 index() count()
tuples = (1, 2, 3, 4, 5)
print(tuples[0])
print(tuples.index(5))
print(tuples.count(3))
# 构造元组,需要传入一个可迭代对象 tuple list dict都是这样使用
# print(tuple(1)) 'int' object is not iterable
print(tuple("huyong"))
lists = ["huyong", "lwt"]
print(tuple(lists))
# join方法
tupleDemo1 = ("1", "2", "3")
print("".join(tupleDemo1))
# 遍历和数组雷同
笔记8-tuple
最新推荐文章于 2024-09-06 07:22:03 发布