摘要: if 条件1: 代码1 elif 条件2: 代码2 else: 代码3 阅读全文
posted @ 2020-03-06 19:15 江湖有梦 阅读(151) 评论(0) 推荐(0) 编辑
摘要: in:用来判断是否存在 例: 'a'in'abcd' (True) 1 in [1,2,3,4,5] (True) name in{name:'jake',age:18} (True) ps:字典中我们只能判断key的存在 not in:用法类似in is:用于判断id是否相等 阅读全文
posted @ 2020-03-06 19:12 江湖有梦 阅读(252) 评论(0) 推荐(0) 编辑
摘要: not,and,or not:将紧跟其后的那个值取反 例:not 31 (True) 2==1 and 5 1 (false) True and false (false) 35 and True and 5==5 (false) ps:两侧都为真的情况下是真,任意一侧为假即为假。(同真为真,一假为 阅读全文
posted @ 2020-03-06 19:07 江湖有梦 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 可变类型:值改变了,id不变。 不可变类型:值变了,id也变了。 int,str,float都是不可变类型 list,dic都是可变类型 ps:在字典中,key必须是不可变类型,value可以是不可变类型,也可以是可变类型。 阅读全文
posted @ 2020-03-06 18:31 江湖有梦 阅读(158) 评论(0) 推荐(0) 编辑