摘要: ##while循环 message = "" while message != 'quit': message = input("Enter 'quit' to end the program: ") if message != 'quit': print(message) ##循环标志 activ 阅读全文
posted @ 2020-10-03 20:00 Harry_666 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 字典是一系列键值对,每个键都与一个值相关联。 ##访问字典的值 alien = {'color':'green','points':5} new_points = alien['points'] print("You just earned " + str(new_points) + " point 阅读全文
posted @ 2020-10-03 19:16 Harry_666 阅读(154) 评论(0) 推荐(0) 编辑
摘要: ##检查相等和不等 ##多个检查条件 age1 = 22 age2 = 19 s1 = age1 > 21 and age2 > 19 print(s1) s2 = age1 > 21 or age2 > 19 print(s2) ##检查是否包含在列表内 requested_toppings = 阅读全文
posted @ 2020-10-03 16:12 Harry_666 阅读(199) 评论(0) 推荐(0) 编辑
摘要: ##遍历元素 magicians = ['alice','david','carolina'] for magician in magicians: print(magician) magicians = ['alice','david','carolina'] for magician in ma 阅读全文
posted @ 2020-10-03 11:37 Harry_666 阅读(168) 评论(0) 推荐(0) 编辑
摘要: ##列表索引 list = ['trek','cannondale','redline','specialized'] print(list[0].title()) ##列表方法 ###修改元素 list = ['trek','cannondale','redline','specialized'] 阅读全文
posted @ 2020-10-03 10:13 Harry_666 阅读(172) 评论(0) 推荐(0) 编辑