10 月 092020
 
#成员运算符Membership Operators(in)与身份运算符Indentify Operators(is)
#集合类型之列表
#字符串,浮点,整数,布尔类型,变量,甚至是另一个列表都可以存储在列表中
album1 = []
#创建一个非空列表
album2 = ['Black Star', 'David Bowie', 25, True]
#使用列表的append方法向列表中添加新的元素
album2.append('new song')
#使用列表索引打印列表中第一个和最后一个元素
print(album2[0], album2[-1])
#打印第二个和倒数第二个元素
#print(album2[1], album2[-2])
#测试字符串Black Star是否存在列表album2中
print('Black Star' in album2)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python39/python.exe c:/Users/harveymei/hello.py
Black Star new song
True
PS C:\Users\harveymei> 

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)