1. print('abs():输出绝对值,是absolute的缩写--------------')
  2. print(abs(-1))
  3.  
  4. print('all()与any()---------------------------')
  5. #all都为真时才为真,但是空的为真,any()有一个为真时就是真的
  6. jo1_list=[1,2,3,4,5,6,7]
  7. jo2_list=['',2,3,4,5,7]
  8. jo4_list=[0,2,3,4,5,6,7]
  9. jo5_list=[False,2,3,4,5,6,7]
  10. jo6_list=[]
  11. jo7_list=[0,'',False]
  12. print('all()列表元素不为空和零',all(jo1_list))
  13. print('all()列表元素包含一个空',all(jo2_list))
  14. print('all()列表元素包含一个0',all(jo4_list))
  15. print('all()列表元素包含一个False',all(jo5_list))
  16. print('all()列表元素为空',all(jo6_list))
  17. print('all()列表元素为空、零和假',all(jo7_list))
  18.  
  19. print('any()列表元素不为空和零',any(jo1_list))
  20. print('any()列表元素包含一个空',any(jo2_list))
  21. print('any()列表元素包含一个0',any(jo4_list))
  22. print('any()列表元素包含一个False',any(jo5_list))
  23. print('any()列表元素为空',any(jo6_list))
  24. print('all()列表元素为空、零和假',any(jo7_list))
  25.  
  26. print('ascii()-----------------------')
  27. print('参数为数字,返回字符串',ascii(10))
  28. print('参数为字符串,返回字符串',ascii('jojojo'))
  29. print('参数为汉字,返回字符串',ascii('呵呵哒'))
  30.  
  31. print('bin()是binary的缩写--------------------------')
  32. print(bin(1))
  33. print(bin(10000**1000))
  34.  
  35. print('bool()---------')
  36. print(bool())
  37. print(bool(0))
  38. print(bool(1))
  39. print(bool(2))
  40.  
  41. print('issubclass()---')
  42. class jo:
  43. pass
  44. class joo(jo):
  45. pass
  46. class jook:
  47. pass
  48. print(issubclass(joo,jo))
  49. print(issubclass(jook,jo))
  1. >>>> bytearray('heheda')
  2. Traceback (most recent call last):
  3. File "<pyshell#28>", line 1, in <module>
  4. bytearray('heheda')
  5. TypeError: string argument without an encoding
  6. >>> bytearray(heheda)
  7. Traceback (most recent call last):
  8. File "<pyshell#29>", line 1, in <module>
  9. bytearray(heheda)
  10. NameError: name 'heheda' is not defined
  11. >>> bytearray('heheda',''utf-8)
  12. SyntaxError: invalid syntax
  13. >>> bytearray('heheda','utf-8')
  14. bytearray(b'heheda')
  15. >>> bytearray('heheda','gb2312')
  16. bytearray(b'heheda')
  17. >>> bytearray('heheda','BIG5')
  18. bytearray(b'heheda')
  19. >>> bytearray('呵呵哒','BIG5')
  20. Traceback (most recent call last):
  21. File "<pyshell#34>", line 1, in <module>
  22. bytearray('呵呵哒','BIG5')
  23. UnicodeEncodeError: 'big5' codec can't encode character '\u54d2' in position 2: illegal multibyte sequence
  24. >>> bytearray('呵呵哒','gb2312')
  25. bytearray(b'\xba\xc7\xba\xc7\xdf\xd5')
  26. >>> bytearray('呵呵哒','utf-8')
  27. bytearray(b'\xe5\x91\xb5\xe5\x91\xb5\xe5\x93\x92')
  28. >>> is
  29. SyntaxError: invalid syntax
  30. >>> isinstance(jojo,str)
  31. Traceback (most recent call last):
  32. File "<pyshell#38>", line 1, in <module>
  33. isinstance(jojo,str)
  34. NameError: name 'jojo' is not defined
  35. >>> isinstance('jojo',str)
  36. True
  37. >>> isinstance('jojo',unicode)
  38. Traceback (most recent call last):
  39. File "<pyshell#40>", line 1, in <module>
  40. isinstance('jojo',unicode)
  41. NameError: name 'unicode' is not defined
  42. >>> isinstance('jojo','utf-8')
  43. Traceback (most recent call last):
  44. File "<pyshell#41>", line 1, in <module>
  45. isinstance('jojo','utf-8')
  46. TypeError: isinstance() arg 2 must be a type or tuple of types
  47. >>> 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. jquery.peity.js简介

    jQuery简单图表peity.js <html xmlns="http://www.w3.org/1999/xhtml"> <head> <titl ...

  2. css3整理--word-wrap/word-break/white-space

    word-wrap语法: word-wrap : normal | break-word normal : 默认值,单词如果单词超长,会冲出边界(单个单词超长,在当前行显示) break-word : ...

  3. jQuery队列(一)

    jQuery的队列依赖缓存机制事件,它同时是animate的基础. 它不像事件机制.缓存机制.回调机制一样有自己的命名空间,由于比较简单,所以直接挂在到$和jQuery对象上. 它提供的基础方法有: ...

  4. css修改select默认样式

    先来看看效果图: css: <style media="screen"> .select_demo, .select_list { width: 400px; heig ...

  5. redmine创建新闻,自动发邮件给项目组所有成员

    redmine创建新闻,自动发邮件给项目组所有成员: 1.添加用户至公共项目内 2.配置系统邮件推送配置 3.检查用户接受推送配置 3.使用管理员账户发布新闻(不能自己发送自己) 4.查看邮件接受邮件

  6. 慕课网,vue高仿饿了吗ASP源码视频笔记

    1.源码笔记 我的源码+笔记(很重要):http://pan.baidu.com/s/1geI4i2Z 感谢麦子学院项目相关视频 2.参考资料 Vue.js官网(https://vuejs.org.c ...

  7. Python数据分析必备Anaconda安装、快捷键、包安装

    Python数据分析必备: 1.Anaconda操作 Anaconda是一个用于科学计算的Python发行版,支持 Linux, Mac, Windows系统,提供了包管理与环境管理的功能,可以很方便 ...

  8. PAT-GPLT L1-039 - 古风排版 - [字符串输入输出]

    题目链接:https://www.patest.cn/contests/gplt/L1-039 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standar ...

  9. pycurl实例详解

    Pycurl是Python的libcurl接口.liburl是客户端的URL传输库,它支持FTP,FTPS,HTTP,HTTPS,TELNET,LDAP等诸多协议,同时支持HTTP认证,代理,FTP上 ...

  10. 替换{0}为指定的字符串(MessageFormat)

    package com.text; import java.text.MessageFormat; /**替换{0}为指定的字符串*/ public class MessageFormatTest { ...