1.not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9 结果会输出啥? 根据优先级:(not 1) or (0 and 1) or (3 and 4) or (5 and 6) or (7 and 8 and 9) 之后剩下:0 or 0 or 4 or 6 or 9 之后根据短路逻辑: 3 and 4 == 4 :3 or 4 == 3 所以最后答案是 4 2.元字符“.”在默认模式下,匹配除换行符外的所有字符.在DOTALL模式下…
1.>>> d = {'x': 'A', 'y': 'B', 'z': 'C' } >>> for k, v in d.iteritems(): ... print k, '=', v ... y = B x = A z = C 2.>>> L = ['Hello', 'World', 'IBM', 'Apple'] >>> [s.lower() for s in L] ['hello', 'world', 'ibm', 'apple…
定义函数: def greet_users(names): #names是形参 """Print a simple greeting to each user in the list.""" for name in names: msg = "Hello, " + name.title() + "!" print(msg) usernames = ['hannah', 'ty', 'margot'] gre…