7_列表、元组和字符串相互转换()

# list(),tuple(),str()

# 字符串变成列表(list)
print(list("Loveyou"))
# ['L', 'o', 'v', 'e', 'y', 'o', 'u']
# 元组变成列表(list)
print(list((1, 2, 3, 4, 5)))
# [1, 2, 3, 4, 5]

# 将一个可迭代对象转换成元组tuple()
print(tuple("Loveyou"))
# ('L', 'o', 'v', 'e', 'y', 'o', 'u')
print(tuple([1, 2, 3, 4, 5]))
# (1, 2, 3, 4, 5)

# 将一个可迭代对象转换成字符串str()
print(str([1, 2, 3, 4, 5]))
————————
# list(),tuple(),str()

# 字符串变成列表(list)
print(list("Loveyou"))
# ['L', 'o', 'v', 'e', 'y', 'o', 'u']
# 元组变成列表(list)
print(list((1, 2, 3, 4, 5)))
# [1, 2, 3, 4, 5]

# 将一个可迭代对象转换成元组tuple()
print(tuple("Loveyou"))
# ('L', 'o', 'v', 'e', 'y', 'o', 'u')
print(tuple([1, 2, 3, 4, 5]))
# (1, 2, 3, 4, 5)

# 将一个可迭代对象转换成字符串str()
print(str([1, 2, 3, 4, 5]))