Beautiful is better than ugly. Explicit is better than im...[作者空间]
method 在一个类中,可能出现三种方法,实例方法、静态方法和类方法,下面来看看三种方法的不同。 实例方法ins...[作者空间]
“_”和” __”的使用 更多的是一种规范/约定,不没有真正达到限制的目的: “_”:以单下划线开头的表示的是pr...[作者空间]
def fs(lst,fil) f=lambda x:not any(p in x for p in fil) r...[作者空间]
list = ["a", "b", "c"]#可修改数组 dictionary = {"a": 0, "b": 1...[作者空间]
decor()仅仅是一个自己定义的函数,@才是使用的核心。 def decor(func): def wrap...[作者空间]
(1) try: f = open("filename.txt") text=f.read() finall...[作者空间]
nums = [55, 44, 33, 22, 11] if all([i > 5 for i in nums])...[作者空间]
print(", ".join(["spam", "eggs", "ham"])) #prints "spam, ...[作者空间]
is是判断地址相同,==是判断值相同 a=1 b=a print(b is a)#True print(a is ...[作者空间]
>>>dic={'1', '2', '3', '4'} >>>print(dic) {'2', '4', '3',...[作者空间]
#good ages=dict(Dave=24,Mary=42,John=58) print(ages.get('...[作者空间]