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()的更多相关文章

  1. Python的内置方法,abs,all,any,basestring,bin,bool,bytearray,callable,chr,cmp,complex,divmod

    Python的内置方法 abs(X):返回一个数的绝对值,X可以是一个整数,长整型,或者浮点数,如果X是一个复数,此方法返回此复数的绝对值(此复数与它的共轭复数的乘积的平方根) >>> ...

  2. 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 ...

  3. 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 ...

  4. Python3语法详解

    一.下载安装 1.1Python下载 Python官网:https://www.python.org/ 1.2Python安装 1.2.1 Linux 平台安装 以下为在Unix & Linu ...

  5. 初始python第三天(三)

    全局变量与局部变量 1.什么是全局变量 在globals中的变量,都是全局变量,全局变量的作用域就是整个程序 NAME = 'alex' def global_test(): name = 'alex ...

  6. Python-3 语法

    #1 Tab键: 1)控制缩进 2)IDLE智能补全 #2 =等号: 1)=:表示赋值 2)==:表示判断 #3 流程图: print('..........小甲鱼_1..........') tem ...

  7. Python模块学习

    6. Modules If you quit from the Python interpreter and enter it again, the definitions you have made ...

  8. 【Python 函数对象 命名空间与作用域 闭包函数 装饰器 迭代器 内置函数】

    一.函数对象 函数(Function)作为程序语言中不可或缺的一部分,但函数作为第一类对象(First-Class Object)却是 Python 函数的一大特性. 那到底什么是第一类对象(Firs ...

  9. 【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 ...

随机推荐

  1. USACO The Clocks

    操作间没有次序关系,同一个操作最多重复3次... 可以直接暴力... The Clocks IOI'94 - Day 2 Consider nine clocks arranged in a 3x3 ...

  2. u-boot.lds文件简介

    可执行文件由许多链接在一起的对象文件组成.对象文件有许多节,如文本.数据.init 数据.bss等.这些对象文件都是由一个称为 链接器脚本(*lds)的文件链接并装入的.这个链接器脚本的功能是将输入对 ...

  3. datatable 使用LAMBDA表达查询,过滤

    DataTable dt = new DataTable(); DataColumn dc = new DataColumn("UserName", System.Type.Get ...

  4. LeetCode 81 Search in Rotated Sorted Array II(循环有序数组中的查找问题)

    题目链接:https://leetcode.com/problems/search-in-rotated-sorted-array-ii/#/description   姊妹篇:http://www. ...

  5. sencha touch Demo(示例)(2014-6-25)

    这是一个开源示例,是我对sencha touch的深层应用.已停止更新 sencha touch版本:2.2.1/2.3.1 源码地址: https://bitbucket.org/moLangZai ...

  6. 使用 Gogs 搭建自己的 Git 服务器

    安装过程分为这些步骤: 新建用户: 下载源码编译 / 下载预编译二进制打包: 运行安装: 配置调整: 配置 nginx 反向代理: 保持服务运行: 注意,这里默认你已经安装好了 MySQL 服务器和 ...

  7. 搭建IPv4专有网络

    搭建IPv4专有网络 版权归属:阿里云网站   本教程将指引您搭建一个具有IPv4地址块的专有网络,并为专有网络中的ECS实例绑定一个弹性公网IP(EIP)进行公网访问. 步骤一:创建专有网络和交换机 ...

  8. 【JSP】EL表达式语言

    EL简介 EL语言原本是JSTL1.0中的技术(所以EL和JSTL配合如此亲密和默契也就是自然的了),但是从JSP2.0开始(JSTL1.1)就分离出来纳入了JSP的标准了.因此EL不需要任何jar包 ...

  9. 【CF802C】Heidi and Library (hard) 费用流

    [CF802C]Heidi and Library (hard) 题意:有n个人依次来借书,第i人来的时候要求书店里必须有种类为ai的书,种类为i的书要花费ci块钱购入.而书店的容量只有k,多余的书只 ...

  10. Unity3D笔记 愤怒的小鸟<七> 小鸟群准备动画

    要实现的目标: 1.3只小鸟初始动画 2.完善代码slingShot.js 3.完善代码BirdMoving.js 1.实现3个准备动画:Unity3D内置的动画管理器 1.1.先选择GameObje ...