print(abs(-1))
print(abs(-1))
#1
print(abs(1))
print(abs(1))
#1
print(all([1,2,'1']))
print(all([1,2,'1','']))
print(all(''))#空元组或者空列表或者空集合为真
print(all([]))
print(all({}))
print(all(()))
'''
True
False
True
True
True
True
'''
print(any([0,'']))
print(any([0,'',1]))
print(any([]))
print(any({}))
print(any(()))
'''
False
True
False
False
False
'''
#返回整数的二进制表示
print(bin(3))#返回整数的二进制表示
0b11
#空,None,0的布尔值为False,其余都为True
print(bool(''))
print(bool(None))
print(bool(0))
False
False
False
#
name='你好'
print(bytes(name,encoding='utf-8'))
print(bytes(name,encoding='utf-8').decode('utf-8'))
print(bytes(name,encoding='gbk'))
print(bytes(name,encoding='gbk').decode('gbk'))
#print(bytes(name,encoding='ascii'))#ascii不能编码中文
b'\xe4\xbd\xa0\xe5\xa5\xbd'
你好
b'\xc4\xe3\xba\xc3'
你好
print(chr(46))
.
print(dir(dict))
['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
2
print(divmod(10,3))
print(divmod(12,3))
(3, 1)
(4, 0)
str
dic={'name':'alex'}
dic_str=str(dic)
print(dic_str)
{'name': 'alex'}
#可hash的数据类型即不可变数据类型,不可hash的数据类型即可变数据类型
print(hash('12sdfdsaf3123123sdfasdfasdfasdfasdfasdfasdfasdfasfasfdasdf'))
print(hash('12sdfdsaf31231asdfasdfsadfsadfasdfasdf23'))
print(hash(('1','2')))
#print(hash(['1','2'])) #不可hash
7665768032629354663
6400811570057356766
-6377284095320480619
#
name='alex'
print(hash(name))
print(hash(name))
-1094992284057724805
-1094992284057724805
#
#
print('--->before',hash(name))
name='sb'
print('=-=>after',hash(name))
--->before -1094992284057724805
=-=>after 8732907780359584531
print(help(all))
Help on built-in function all in module builtins:
all(iterable, /)
Return True if bool(x) is True for all values x in the iterable.
If the iterable is empty, return True.
None
print(bin(10))#10进制->2进制
print(hex(12))#10进制->16进制
print(oct(12))#10进制->8进制
0b1010
0xc
0o14
数据类型
print(isinstance(1,int))
print(isinstance('abc',str))
print(isinstance([],list))
print(isinstance({},dict))
print(isinstance({1,2},set))
print(isinstance(1,str))
#判定数据类型
True
True
True
True
True
False
name='哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈粥少陈'
print(globals()) # globals 函数返回一个全局变量的字典,包括所有导入的变量。
#print(__file__)
#
# def test():
# age='1111111111111111111111111111111111111111111111111111111111111'
# # print(globals())
# print(locals())
#
# test()
l=[1,3,100,-1,2]
print(max(l))
print(min(l))