Python 内置函数:https://www.runoob.com/python/python-built-in-functions.html

原文:https://www.cnblogs.com/linhaifeng/articles/6113086.html#_label12

# 绝对值
# print(abs(-1))
# print(abs(1))
#
# 有一个为假就false,如果为空就是true
# Return True if bool(x) is True for all values x in the iterable.
# If the iterable is empty, return True.
# print(all([1,2,'1']))#True
# print(all([1,2,'1','']))#False
# print(all('1230'))#True
# print(all(''))#True # 有一个是真,就是true
# print(any([0,'']))
# print(any([0,'',1])) # 转2进制
# print(bin(3)) #空,None,0的布尔值为False,其余都为True
# print(bool(''))
# print(bool(None))
# print(bool(0)) # 加码解码
# 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不能编码中文 # chr() 用一个范围在 range(256)内的(就是0~255)整数作参数,返回一个对应的字符。
# print(chr(46)) # dir() 函数不带参数时,返回当前范围内的变量、方法和定义的类型列表;
# 带参数时,返回参数的属性、方法列表。如果参数包含方法__dir__(),该方法将被调用。
# 如果参数不包含__dir__(),该方法将最大限度地收集参数信息。
# print(dir(dict)) # python divmod() 函数把除数和余数运算结果结合起来,返回一个包含商和余数的元组(a // b, a % b)。
# print(divmod(10,3)) # dic={'name':'alex'}
# dic_str=str(dic)
# print(dic_str) #可hash的数据类型即不可变数据类型,不可hash的数据类型即可变数据类型
# print(hash('12sdfdsaf3123123sdfasdfasdfasdfasdfasdfasdfasdfasfasfdasdf'))
# print(hash('12sdfdsaf31231asdfasdfsadfsadfasdfasdf23'))
#
# name='raito'
# print(hash(name))
# print(hash(name))
#
#
# print('--->before',hash(name))
# name='sb'
# print('=-=>after',hash(name)) # help() 函数用于查看函数或模块用途的详细说明。
# print(help(all))Python 内置函数 # print(bin(10))#10进制->2进制
# print(hex(12))#10进制->16进制
# print(oct(12))#10进制->8进制 # isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()。
#
# isinstance() 与 type() 区别:
#
# type() 不会认为子类是一种父类类型,不考虑继承关系。
#
# isinstance() 会认为子类是一种父类类型,考虑继承关系。
#
# 如果要判断两个类型是否相同推荐使用 isinstance()。 # print(isinstance(1,int))
# print(isinstance('abc',str))
# print(isinstance([],list))
# print(isinstance({},dict))
# print(isinstance({1,2},set)) # name='奋斗奋斗奋斗东方的'
# print(globals())
# print(__file__)
#
# def test():
# age='1111111111111111111111111111111111111111111111111111111111111'
# # print(globals())
# print(locals())
#
# test() # l=[1,3,100,-1,2]
# print(max(l))
# print(min(l))

16.python内置函数的更多相关文章

  1. python内置函数

    python内置函数 官方文档:点击 在这里我只列举一些常见的内置函数用法 1.abs()[求数字的绝对值] >>> abs(-13) 13 2.all() 判断所有集合元素都为真的 ...

  2. python 内置函数和函数装饰器

    python内置函数 1.数学相关 abs(x) 取x绝对值 divmode(x,y) 取x除以y的商和余数,常用做分页,返回商和余数组成一个元组 pow(x,y[,z]) 取x的y次方 ,等同于x ...

  3. Python基础篇【第2篇】: Python内置函数(一)

    Python内置函数 lambda lambda表达式相当于函数体为单个return语句的普通函数的匿名函数.请注意,lambda语法并没有使用return关键字.开发者可以在任何可以使用函数引用的位 ...

  4. Python内置函数进制转换的用法

    使用Python内置函数:bin().oct().int().hex()可实现进制转换. 先看Python官方文档中对这几个内置函数的描述: bin(x)Convert an integer numb ...

  5. 【转】python 内置函数总结(大部分)

    [转]python 内置函数总结(大部分) python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为 ...

  6. python内置函数,匿名函数

    一.匿名函数 匿名函数:为了解决那些功能很简单的需求而设计的一句话函数 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc = lambda n ...

  7. python 内置函数总结(大部分)

    python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是pytho ...

  8. python内置函数大全(分类)

    python内置函数大全 python内建函数 最近一直在看python的document,打算在基础方面重点看一下python的keyword.Build-in Function.Build-in ...

  9. python内置函数详细介绍

    知识内容: 1.python内置函数简介 2.python内置函数详细介绍 一.python内置函数简介 python中有很多内置函数,实现了一些基本功能,内置函数的官方介绍文档:    https: ...

随机推荐

  1. FinalShell for Mac

    Mac一键安装脚本 curl -o finalshell_install.sh www.hostbuf.com/downloads/finalshell_install.sh;chmod +x fin ...

  2. Spring Security 的登录密码验证过程 UsernamePasswordAuthenticationFilter

    认证过程如下 一.先判断请求(请求必须是post请求)地址是否为配置的 login-processing-url 值(默认/j_spring_security_check),如果不是,则放行,进入下一 ...

  3. Python基础:04映射类型

    字典是Python语言中唯一的映射类型.一个字典对象是可变的,它是一个容器类型,能存储任意个数的Python对象.字典中的数据是无序排列的. 映射类型也可被称做哈希表,哈希表的算法是获取键,对键执行一 ...

  4. windows 下的 Apache 二级域名 目录绑定配置

    通常我们注册的域名都是顶级域名  如 www.potatog.com,我们希望这个域名可以访问服务器的不同网站或者不同功能等等 可能会这样 www.potatog.com/api 或者 www.pot ...

  5. [***]HZOJ 优美序列

    又是一道神仙题.考试的时候居然打了一个回滚莫队,不知道我咋想的…… 先说一个某OJT80,洛谷T5分的思路(差距有点大): 可以把位置和编号映射一下,区间内最大值和最小值对应的位置,每次更新,直到找到 ...

  6. sspanel 常用审计规则

    规则 禁用 BT 防止版权争议 BitTorrent protocol 数据包明文匹配 禁止 百度高精度定位 防止IP与客户端地理位置被记录 (api|ps|sv|offnavi|newvector| ...

  7. Android 高仿QQ滑动弹出菜单标记已读、未读消息

    在上一篇博客<Android 高仿微信(QQ)滑动弹出编辑.删除菜单效果,增加下拉刷新功能>里,已经带着大家学习如何使用SwipeMenuListView这一开源库实现滑动列表弹出菜单,接 ...

  8. behavior planning——13. implement a cost function in C++

    In the previous quizzes, you designed a cost function to choose a lane when trying to reach a goal i ...

  9. vue 项目编译打包

    1. npm run build 2. npm install -g serve 3.serve dist 原文地址:https://www.cnblogs.com/jy13638593346/p/9 ...

  10. H3C 广域网连接方式