Build-in Function:abs(),all(),any(),assii(),bin(),issubclass(),bytearray(),isinstance()
print('abs():输出绝对值,是absolute的缩写--------------')
print(abs(-1))
print('all()与any()---------------------------')
#all都为真时才为真,但是空的为真,any()有一个为真时就是真的
jo1_list=[1,2,3,4,5,6,7]
jo2_list=['',2,3,4,5,7]
jo4_list=[0,2,3,4,5,6,7]
jo5_list=[False,2,3,4,5,6,7]
jo6_list=[]
jo7_list=[0,'',False]
print('all()列表元素不为空和零',all(jo1_list))
print('all()列表元素包含一个空',all(jo2_list))
print('all()列表元素包含一个0',all(jo4_list))
print('all()列表元素包含一个False',all(jo5_list))
print('all()列表元素为空',all(jo6_list))
print('all()列表元素为空、零和假',all(jo7_list))
print('any()列表元素不为空和零',any(jo1_list))
print('any()列表元素包含一个空',any(jo2_list))
print('any()列表元素包含一个0',any(jo4_list))
print('any()列表元素包含一个False',any(jo5_list))
print('any()列表元素为空',any(jo6_list))
print('all()列表元素为空、零和假',any(jo7_list))
print('ascii()-----------------------')
print('参数为数字,返回字符串',ascii(10))
print('参数为字符串,返回字符串',ascii('jojojo'))
print('参数为汉字,返回字符串',ascii('呵呵哒'))
print('bin()是binary的缩写--------------------------')
print(bin(1))
print(bin(10000**1000))
print('bool()---------')
print(bool())
print(bool(0))
print(bool(1))
print(bool(2))
print('issubclass()---')
class jo:
pass
class joo(jo):
pass
class jook:
pass
print(issubclass(joo,jo))
print(issubclass(jook,jo))
>>>> bytearray('heheda')
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
bytearray('heheda')
TypeError: string argument without an encoding
>>> bytearray(heheda)
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
bytearray(heheda)
NameError: name 'heheda' is not defined
>>> bytearray('heheda',''utf-8)
SyntaxError: invalid syntax
>>> bytearray('heheda','utf-8')
bytearray(b'heheda')
>>> bytearray('heheda','gb2312')
bytearray(b'heheda')
>>> bytearray('heheda','BIG5')
bytearray(b'heheda')
>>> bytearray('呵呵哒','BIG5')
Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
bytearray('呵呵哒','BIG5')
UnicodeEncodeError: 'big5' codec can't encode character '\u54d2' in position 2: illegal multibyte sequence
>>> bytearray('呵呵哒','gb2312')
bytearray(b'\xba\xc7\xba\xc7\xdf\xd5')
>>> bytearray('呵呵哒','utf-8')
bytearray(b'\xe5\x91\xb5\xe5\x91\xb5\xe5\x93\x92')
>>> is
SyntaxError: invalid syntax
>>> isinstance(jojo,str)
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
isinstance(jojo,str)
NameError: name 'jojo' is not defined
>>> isinstance('jojo',str)
True
>>> isinstance('jojo',unicode)
Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
isinstance('jojo',unicode)
NameError: name 'unicode' is not defined
>>> isinstance('jojo','utf-8')
Traceback (most recent call last):
File "<pyshell#41>", line 1, in <module>
isinstance('jojo','utf-8')
TypeError: isinstance() arg 2 must be a type or tuple of types
>>> isinstance('jojo','utf-8')
Build-in Function:abs(),all(),any(),assii(),bin(),issubclass(),bytearray(),isinstance()的更多相关文章
- Python的内置方法,abs,all,any,basestring,bin,bool,bytearray,callable,chr,cmp,complex,divmod
Python的内置方法 abs(X):返回一个数的绝对值,X可以是一个整数,长整型,或者浮点数,如果X是一个复数,此方法返回此复数的绝对值(此复数与它的共轭复数的乘积的平方根) >>> ...
- the simmon effect(in psychology) :build the function of subject_information(modify the experiment programme),before we begin the experiment
#the real experiment for simon effect #load the library which is our need import pygame import sys i ...
- simon effect (psychology experiment ) : build the function of wait4key()
## #the real experiment for simon effect #load the library which is our need import pygame import sy ...
- Python3语法详解
一.下载安装 1.1Python下载 Python官网:https://www.python.org/ 1.2Python安装 1.2.1 Linux 平台安装 以下为在Unix & Linu ...
- 初始python第三天(三)
全局变量与局部变量 1.什么是全局变量 在globals中的变量,都是全局变量,全局变量的作用域就是整个程序 NAME = 'alex' def global_test(): name = 'alex ...
- Python-3 语法
#1 Tab键: 1)控制缩进 2)IDLE智能补全 #2 =等号: 1)=:表示赋值 2)==:表示判断 #3 流程图: print('..........小甲鱼_1..........') tem ...
- Python模块学习
6. Modules If you quit from the Python interpreter and enter it again, the definitions you have made ...
- 【Python 函数对象 命名空间与作用域 闭包函数 装饰器 迭代器 内置函数】
一.函数对象 函数(Function)作为程序语言中不可或缺的一部分,但函数作为第一类对象(First-Class Object)却是 Python 函数的一大特性. 那到底什么是第一类对象(Firs ...
- 【python】BIF及查看函数帮助
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32 Type ...
随机推荐
- django进阶-查询(适合GET4以上人群阅读)
前言: 下篇博客写关于bootstrap... 一.如何在脚本测试django from django.db import models class Blog(models.Model): name ...
- icon VS html特殊字符
好久没来了,最近项目很多,今天要说的是个页面上用到的icon. 话“icon” 现在有很多icon库,我们再也不用切图来适配不同的分辨率了,但是对于新手来说,查阅icon库来找到适合的icon,实在费 ...
- chorme 浏览器记住密码后input黄色背景处理
使用chrome浏览器选择记住密码的账号,输入框会自动加上黄色的背景,有些设计输入框是透明背景的,需要去除掉这个黄色的背景: 方法1:阴影覆盖 input:-webkit-autofill { -we ...
- SharpGL学习笔记(二) 模型变换(几何变换)
(二) 模型变换 模形变换就是指的在世界坐标系中(world space)做“移动”,“旋转", "缩放"三种操作. 首先要说明的,在Opengl中,是用4x4矩阵进行坐 ...
- 动力学仿真引擎ODE的学习笔记,C#演示(一)
®版权声明:本文为博主原创文章,未经博主允许不得转载. 一.ODE介绍与平台搭建. 接触到动力学仿真引擎, 是因为笔者的一款PLC仿真软件需要3D仿真.我需要达到的效果是,以3D方式构建出工控行业中常 ...
- 游戏AI-行为树
参考: 游戏AI—行为树研究及实现 GAD腾讯游戏开发者平台:游戏中的人工智能AI 腾讯开源项目behaviac 占坑,待编辑
- 在 NHibernate 中一切必须是 Virtual 的吗?
原文地址:Must Everything Be Virtual With NHibernate? 老赵在博文中 我对NHibernate的感受(2):何必到处都virtual 提到这篇文章,顺便翻译一 ...
- kvm/qemu虚拟机桥接网络创建与配置
首先阐述一下kvm与qemu的关系,kvm是修改过的qemu,而且使用了硬件支持的仿真,仿真速度比QEMU快. 配置kvm/qemu的网络有两种方法.其一,默认方式为用户模式网络(Usermode N ...
- Windows Server 2008 R2之六活动目录域服务的卸载
活动目录域服务的卸载是将DC降级为独立服务器或成员服务器的过程. 在删除活动目录之前,为了防止操作失败操作系统故障,须对系统进行备份.同时,我们还必须对待删除的域控制器进行如下检查 1.是否有操作主控 ...
- 伪随机数生成算法-梅森旋转(Mersenne Twister/MT)
今天主要是来研究梅森旋转算法,它是用来产生伪随机数的,实际上产生伪随机数的方法有很多种,比如线性同余法, 平方取中法等等.但是这些方法产生的随机数质量往往不是很高,而今天介绍的梅森旋转算法可以产生高质 ...