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 ... 
随机推荐
- Nokia 920全部CODE
			code码都是7位,我是从别的地方copy过来的,code码后面带了些乱码懒得删了,自己数7位code就是了. RM-820 NDT AMERICA ATT White 059N5T3R ... 
- SocketAsyncEventArgs的释放问题
			起因是发现一个同事编写的程序运行两个月左右,占用了服务器20G左右的内存.用WinDbg查看发现存在大量的Async Pinned Handles,而它们的gcroot都来自于SocketAsyncE ... 
- MFC创建好的对话框如何移植到新程序中
			1.用文本文件打开需要移植对话框工程中的rc文件 2.在RC文件夹中找到需要移植的对话框内容,然后拷贝到新的工程的rc文件中 3.在原有工程的rsource.h中所有和这个对话框有关的ID都拷贝到新的 ... 
- Win8安装msi程序出现2502、2503错误解决方法
			在Win8中,在安装msi安装包的时候常常会出现代码为2502.2503的错误.其实这种错误是由于安装权限不足造成的,因为这种msi的安装包不像其他exe的安装程序, 在安装包上点击"右键& ... 
- 【CF802C】Heidi and Library (hard) 费用流
			[CF802C]Heidi and Library (hard) 题意:有n个人依次来借书,第i人来的时候要求书店里必须有种类为ai的书,种类为i的书要花费ci块钱购入.而书店的容量只有k,多余的书只 ... 
- OSS命令行工具ossutil
			ossutil工具旨在为您提供一个以命令行方式管理OSS数据的途径.当前版本未提供完整的Bucket和Multipart管理功能,相关功能会在后续版本中开发.如果您需要使用上述功能,建议先使用ossc ... 
- Java-02-动手动脑
			产生纯随机数 1.设计思想:利用随机数产生公式,递归调用,输出一定数量的随机数. 2.源代码: import java.util.Scanner; public class Suiji_2 { pub ... 
- springMVC + quartz实现定时器(任务调度器)
			首先我们要知道任务调度器(定时器)有几种,这边我会写三种 第一种是基于JDK的本身的一个定时器(优点:简单,缺点:满足不了复杂的需求) package com.timer1; import java. ... 
- XTU 1267 - Highway - [树的直径][2017湘潭邀请赛H题(江苏省赛)]
			这道题可能有毒……总之一会儿能过一会儿不能过的,搞的我很心烦…… 依然是上次2017江苏省赛的题目,之前期末考试结束了之后有想补一下这道题,当时比较懵逼不知道怎么做……看了题解也不是很懂……就只好放弃 ... 
- Rhino
			http://shrinksafe.dojotoolkit.org/ a JavaScript interpreter 
