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. 亚洲唯一,阿里云SLB位列Gartner全球网络负载均衡市场前五

    近日,Gartner发布了最新的全球企业级网络设备市场份额报告“Market Share: Enterprise Network Equipment by Market Segment, Worldw ...

  2. 什么是实例化? 标签: vb 2015-02-08 20:26 1026人阅读 评论(30) 收藏

    为什么要写这个博客呢?可能是因为自己的基础太差,昨天敲三层的注册,各层都敲完了以后,死活报错,无奈之下只能找晓婵求救,她只改了三个地方,犯了同一个错误,我的源码是这样写的:Dim uA As  Ent ...

  3. LeetCode67 Add Binary

    题目: Given two binary strings, return their sum (also a binary string). (Easy) For example,a = " ...

  4. 2019-6-5-VisualStudio-开启仅我代码调试

    title author date CreateTime categories VisualStudio 开启仅我代码调试 lindexi 2019-06-05 19:29:44 +0800 2019 ...

  5. 2019-8-31-dotnet-通过-WMI-获取设备厂商

    title author date CreateTime categories dotnet 通过 WMI 获取设备厂商 lindexi 2019-08-31 16:55:59 +0800 2019- ...

  6. 2019-1-29-Moq基础-判断方法被执行

    title author date CreateTime categories Moq基础 判断方法被执行 lindexi 2019-01-29 16:29:57 +0800 2019-01-17 1 ...

  7. iPython的安装过程

    http://blog.csdn.net/u012587561/article/details/50900781 python2.7.10 amd64 win10 x64 1. 安装setuptool ...

  8. Git Commit Message 规范

    今天来说说团队开发中,对于 Git commit message 规范问题. 社区上有各种 Commit message 的规范,本文介绍 Angular 规范,目前使用较广,比较合理和系统化,并且有 ...

  9. gradle在build的时候找不到某个jar包的解决办法

    前几天公司来新人, 我给他装项目环境的时候遇到一个问题, 在执行gradle build时遇到一系列的错误, 我一个个分析并解决了, 特此记录, 以供他人参考. 一, 首先遇到了找不到spring-b ...

  10. 2019-10-24-dotnet-列表-Linq-的-Take-用法

    title author date CreateTime categories dotnet 列表 Linq 的 Take 用法 lindexi 2019-10-24 9:4:23 +0800 201 ...