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 ...
随机推荐
- 【Spring Boot && Spring Cloud系列】Spring Boot的启动器Starter
Spring Boot的内置Servlet Container: Name Servlet Version Java Version Tomcat8 3.1 Java 7+ Tomcat7 3.0 J ...
- 【Spring Boot&&Spring Cloud系列】提高数据库访问性能
前言 使用关系型数据库的应用系统的性能瓶颈最终还是数据库.随着业务的迅速增长,数据量会不断增大,会逐渐暴露关系型数据库的弱点,性能会大幅度的降低 项目地址:https://github.com/And ...
- VC++中如何复制对话框资源
法1: 在你的工程中添加另一个工程的rc文件,这时资源视图中就会出现两个rc,从后加的rc中拷贝资源到你自己工程的rc中就可以了. 法2:vc中如何拷贝一个工程的对话框资源到另一个工程 ...
- Eclipse 创建和读取yaml文件
工具和用法: 1. eclipse插件包:org.dadacoalition.yedit_1.0.20.201509041456-RELEASE.jar 用法:将此jar包复制到eclipse-jee ...
- 一、laya学习笔记 --- layabox环境搭建 HelloWorld(坑:ts版本问题解决方案)
好吧,使用layabox需要从官网下载些啥呢 一.下载layabox 官网 https://www.layabox.com/ 首页上有两个,一个Engine,一个IDE Engine我下载的TS版本, ...
- TX大手笔做业务必然失败的原因
首先说一个伪命题: 物体会向下落这是一个基本的定律,一个小小的物理规则会覆盖所有物体的行为准则. 那么,当地球上的所有东西都下落的时候,你指望整个地球,月球,太阳也会下落么? 事实上大家都知道星球在宇 ...
- Thinkphp框架下对某个字段查询数据的时候进行唯一过滤,返回唯一不同的值
方法一. DISTINCT 方法用于返回唯一不同的值 . *distinct方法的参数是一个布尔值. 用法: $data = $Model->Distinct(true)->field(' ...
- Elasticsearch 与 Mongodb 数据同步问题
1.mongo-connector工具 首先安装python环境 wget http://www.python.org/ftp/python/3.0.1/Python-3.0.1.tgz tar -z ...
- Centos6.5 (或Linux) 安装Elasticsearch
一.可以在网上下载对饮的版本:https://github.com/elastic/elasticsearch,本次安装的是5.5.3. 首先保证虚拟机上安装了jdk,jdk的版本只是是1.7或以上 ...
- PowerDesigner 把Comment/name 互转
转载:https://www.cnblogs.com/cxd4321/archive/2009/03/07/1405475.html 在使用PowerDesigner对数据库进行概念模型和物理模型设计 ...