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. 非IMU模式下DML语句产生的REDO日志内容格式解读

    实验内容:非IMU模式下DML语句产生的REDO日志内容格式解读 最详细的解读是UPDATE的. 实验环境准备 11G中默认是开启IMU特性的,做此实验需要关闭此特性. alter system se ...

  2. 安卓下junit测试

    安卓下junit测试 第一种方法: 1,在AndroidManifest.xml下,加入如下红色代码 <manifest xmlns:android="http://schemas.a ...

  3. c++ 用new创建二维数组~创建指针数组【转】

    #include <iostream> using namespace std; void main() { //用new创建一个二维数组,有两种方法,是等价的 //一: ] = ][]; ...

  4. 【前端积累】Awesome初识

    前言 之所以要看这个,是因为在看到的一个网站里图表显示的全屏和缩小,anyway ,还是看一下咯~ 一.介绍 Font Awesome 字体为您提供可缩放矢量图标,它可以被定制大小.颜色.阴影以及任何 ...

  5. Visual Studio 2013附加进程调试IE加载的ActiveX Control无效解决方法

    默认Attach to选择了Automatically determine the type of code to debug,显示Native Code.但附加进程到iexplore.exe断点无法 ...

  6. jQuery 核心 - noConflict() 方法

    1.遇到问题: 当我们写jquery时使用$,发现写的jquery全部失效: 2.发现问题: 排查后发现是noConflict()函数在作怪,因为使用noConflict()函数后,重新定义$名字为j ...

  7. python3中如何区分一个函数和方法

    一般情况下,单独写一个def func():表示一个函数,如果写在类里面是一个方法.但是不完全准确. class Foo(object): def fetch(self): pass print(Fo ...

  8. RestTemplate异常no suitable HttpMessageConverter found for request type [java.lang.Integer]

    GET方式,参数必须放在URL后面,http://xxx/list?name={name}&age={age} package com.chelizi.xiruo.xframework.uti ...

  9. 专访|HPE测试中心总监徐盛:测试新思维-DevOps,持续测试,更敏捷,更快速

    2016年7月22日,「HPE&msup软件技术开放日」将在上海浦东新区,张江高科技园区纳贤路799号科荣大厦小楼2楼举办,msup携手HPE揭秘全球测试中心背后的12条技术实践. 徐盛:HP ...

  10. C++基础知识之动态库静态库

    一. 静态库与动态库 库(library),一般是一种可执行的二进制格式,被操作系统载入内存执行. 我们通常把一些公用函数制作成函数库,供其它程序使用.函数库分为静态库和动态库 静态库和动态库区别: ...