##列表创建###
#数值类型: int, float, (long), complex,
# 布尔类型:
# 字符串:
# 列表:
# 数组: 存储同一种数据类型的集和。scores=[12,95.5]
# 列表(打了激素的数组): 可以存储任意数据类型的集和。
li = [1, 1.2, 2j+3, True, "hello"]
print(li, type(li))
# 列表里面也是可以嵌套列表的;
li1 = [1, 1.2, 2j+3, True, "hello", [1,2,3,4,5]]
print(li1, type(li1))
###列表的特性###
services = ['http', 'ssh', 'ftp']
# 索引
# 正向索引
print(services[0])
# 反向索引
print(services[-1])
# 切片
print(services[::-1]) # 列表的反转
print(services[1:]) # 除了第一个之外的其他元素
print(services[:-1]) # 除了最后一个之外的其他元素
# 重复
print(services*3)
# 连接
services1 = ['mysql', 'firewalld']
print(services + services1)
# 成员操作符
print('firewalld' in services)
print('ftp' in services)
print('firewalld' not in services)
print('ftp' not in services)
# 列表里面嵌套列表
services2 = [['http', 80], ['ssh', 22], ['ftp',21]]
# 索引
print(services2[0][0])
print(services2[-1][1])
# 切片
#
print(services2[:][1])
print(services2[:-1][0])
print(services2[0][:-1])
# 如何for循环遍历
print("服务显示".center(50, "*"))
for service in services:
# print输出不换行,
print(service, end=',')
# python2:print不换行
# print "hello",
# python3:
print("hello", end=',')
##列表练习-季节###
"""
5. 根据用于指定月份,打印该月份所属的季节。
**提示: 3,4,5 春季 6,7,8 夏季 9,10,11 秋季 12, 1, 2 冬季
"""
month = int(input('Month:')) if month in [3, 4, 5]: print("春季