>>> True True >>> type(True) <class 'bool'>
>>> True = 1 SyntaxError: can't assign to keyword
>>> False False >>> type(False) <class 'bool'>
>>> False = 0 SyntaxError: can't assign to keyword
>>> None #表示无,没有内容输出 >>> type(None) <class 'NoneType'>
>>> None = 2 SyntaxError: can't assign to keyword
>>> def sayHello(): #定义函数
print('Hello')
>>> sayHello()
Hello
>>> result = sayHello()
Hello
>>> result
>>> type(result)
<class 'NoneType'>
>>> NotImplemented NotImplemented >>> type(NotImplemented) <class 'NotImplementedType'>
>>> bool(NotImplemented) True
>>> bool(NotImplemented) True >>> NotImplemented = False >>> >>> bool(NotImplemented) False
>>> class A(object):
def __init__(self,name,value):
self.name = name
self.value = value
def __eq__(self,other):
print('self:',self.name,self.value)
print('other:',other.name,other.value)
return self.value == other.value #判断2个对象的value值是否相等
>>> a1 = A('Tom',1)
>>> a2 = A('Jay',1)
>>> a1 == a2
self: Tom 1
other: Jay 1
True
>>> class A(object):
def __init__(self,name,value):
self.name = name
self.value = value
def __eq__(self,other):
print('self:',self.name,self.value)
print('other:',other.name,other.value)
return NotImplemented
>>> a1 = A('Tom',1)
>>> a2 = A('Jay',1)
>>> a1 == a2
self: Tom 1
other: Jay 1
self: Jay 1
other: Tom 1
False
>>> Ellipsis Ellipsis >>> type(Ellipsis) <class 'ellipsis'> >>> ... Ellipsis >>> ... == Ellipsis True
>>> bool(Ellipsis) True
>>> bool(Ellipsis) True >>> Ellipsis = False >>> bool(Ellipsis) False
>>> a = [1,2,3,4] >>> a.append(a) >>> a [1, 2, 3, 4, [...]] >>> a [1, 2, 3, 4, [...]] >>> len(a) >>> a[4] [1, 2, 3, 4, [...]] >>>
>>> __debug__ True >>> type(__debug__) <class 'bool'>
>>> __debug__ = False SyntaxError: assignment to keyword
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有