# 数据结构 字符串 列表 元组 数字序列
# 10-19的整数
# r1 = range(10,20)
# print(r1)
# print(type(r1))
#
# # 19
# print(r1[9])
#
# # range(13, 17)
# print(r1[3:7])
# 增加步长
# r2 = range(10,20,2)
# print(r2) 10,12,14,16,18
# # 18
# print(r2[4])
# # True
# print(12 in range(10,20))
# 利用range 遍历其他序列
# c = ‘abcdefg‘
# for i in range(0, len(c)):
# letter = c[i]
# print(letter)
# 斐波那契数列
# result = []
# for i in range(0,10):
# if i == 0 or i == 1:
# result.append(1)
# else:
# result.append(result[i - 2] + result[i - 1])
#
# # [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
# print(result)
# 判断质数
# l = 776351721
# is_prime = True
# for i in range(2, l):
# if l %i == 0:
# # 3
# print(i)
# is_prime = False
# break
# # False
# print(is_prime)
# 序列的转换
l1 = [‘a‘,‘b‘,‘c‘]
t1 = (‘d‘,‘e‘,‘f‘)
s1 = ‘abc123‘
s2 = ‘abc,123‘
r1 = range(1,15)
l2 = list(t1)
# str join 对列表进行连接
# abc
print("".join(l1))
# d|e|f
print("|".join(t1))
s3 = ‘‘
for i in r1:
s3 += str(i)
# 1234567891011121314
print(s3)
# # [‘d‘, ‘e‘, ‘f‘]
# print(l2)
# # [‘a‘, ‘b‘, ‘c‘, ‘,‘, ‘1‘, ‘2‘, ‘3‘]
# print(list(s1))
# # [‘abc‘, ‘123‘]
# print(s2.split(","))
# # [1, 2, 3]
# print(list(r1))
# tuple() - 转换为元组
# # (‘a‘, ‘b‘, ‘c‘)
# print(tuple(l1))
# # (‘a‘, ‘b‘, ‘c‘, ‘1‘, ‘2‘, ‘3‘)
# print(tuple(s1))
# # (‘abc‘, ‘123‘)
# print(tuple(s2.split(",")))
# # (1, 2, 3)
# print(tuple(r1))
原文:https://www.cnblogs.com/ericblog1992/p/11273258.html