abs(number)  絕對值 

The abs() method takes a single argument:

   num - number whose absolute value is to be returned. The number can be:

  1. integer
  2. floating number
  3. complex number

any(iterable)  

The any() method returns True if any element of an iterable is True. If not, any() returns False.

*iterable(list, string, dictionary, tumple ...)

  • True if at least one element of an iterable is true
  • False if all elements are false or if an iterable is empty  (表 "0", "False", empty

all(iterable)

The all() method returns True when all elements in the given iterable are true. If not, it returns False.

ascii(object)   ascii編碼(拉丁字母)

The ascii() method returns a string containing a printable representation of an object. It escapes the non-ASCII characters in the string using \x, \u or \U escapes.

*object (like: stringslist etc).

bin(num)  轉二進制

The bin() method converts and returns the binary equivalent string of a given integer. If the parameter isn't an integer, it has to implement __index__() method to return an integer.

  • num - an integer number whose binary equivalent is to be calculated.
    • If not an integer, should implement __index__() method to return an integer
number = 5
print('The binary equivalent of 5 is:', bin(number))
The binary equivalent of 5 is: 0b101

bool([value])  轉布爾值

The bool() method converts a value to Boolean (True or False) using the standard truth testing procedure.

  The following values are considered false in Python:

  • None
  • False
  • Zero of any numeric type. For example, 00.00j
  • Empty sequence. For example, ()[]''.
  • Empty mapping. For example, {}
  • objects of Classes which has __bool__() or __len()__ method which returns 0 or False

bytearray([source[, encoding[, errors]]])

The bytearray() method returns a bytearray object which is a mutable (can be modified) sequence of integers in the range 0 <=x < 256.

If you want the immutable version, use bytes([source[, encoding[, errors]]]) method.

callable(object)  object是否定義過
The callable() method returns True if the object passed appears callable. If not, it returns False.

chr(i)  回傳unicode的對應值

The chrt() method returns a character (a string) from an integer (represents unicode code point of the character).

compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1) 

The compile() method returns a Python code object from the source (normal string, a byte string, or an AST object).

The code object returned by the compile() method can later be called using methods like: exec() and eval() which will execute dynamically generated Python code.

 exec(object, globals, locals)

The exec() method executes the dynamically created program, which is either a string or a code object.

 eval(expression, globals=None, locals=None)

The eval() method parses the expression passed to this method and runs python expression (code) within the program.

 classmethod(function)

The classmethod() method returns a class method for the given function.

  • function - Function that needs to be converted into a class method

@classmethod   高端裝飾,接在 def Person.printAge()之前,效果同等 Person.printAge = classmethod(Person.printAge)

未完待續

https://www.programiz.com/python-programming/methods/built-in/classmethod

Python开发 標準內建方法 (未完代補)的更多相关文章

  1. Python开发 基礎知識 (未完代補)

    一.Python基本知識 1.Python屬高階語言,所編築的是字節碼 2.一般狀態statement 終止於換行,如需使用多數行編寫,可在行末加上 \,以表延續 但在 parentheses ( ) ...

  2. 查看Python的版本、内建方法和模块等内容的方法

    若想更好地应用Python帮助我们解决日常生活的问题,就必须了解清楚它的内建方法和模块等特性.相信不少同学在安装某个版本的Python后,对于内建方法之类都是一知半解,希望本文能帮助了解Python的 ...

  3. windows下Python开发错误记录以及解决方法

    windows下使用pip提示ImportError: cannot import name 'main' 原因:将pip更新为10.0.0后库里面的函数有所变动造成这个问题 解决方法:先卸载现在的p ...

  4. python快速学习-常用內建模块

  5. python开发必备pycharm专业版破解方法

    修改hosts文件 添加下面一行到hosts文件,目的是屏蔽掉Pycharm对激活码的验证 0.0.0.0 account.jetbrains.com 注:hosts文件路径,Windows在C:\W ...

  6. python开发_configparser_解析.ini配置文件工具_完整版_博主推荐

    # # 最近出了一趟差,是从20号去的,今天回来... # 就把最近学习的python内容给大家分享一下... # ''' 在python中,configparser模块提供了操作*.ini配置文件的 ...

  7. python开发_gzip_压缩|解压缩gz文件_完整版_博主推荐

    ''' gzip -- 支持gzip文件 源文件:Lib/gzip.py 这个模块提供了一些简单的接口来对文件进行压缩和解压缩,类似于GNU项目的gzip和gunzip. 数据的压缩源于zlib模块的 ...

  8. 日常开发自己遇到异常(BUG未完待续!!!)

    在面试的时候经常会被问到你在项目中遇到的bug有哪些,或者你感觉你解决什么问题让你感觉有成就感.以此类似的面试问答,楼主现在开始不断更新日常遇到的BUG汇总 1:ConcurentModificati ...

  9. Python基础:内置异常(未完待续)

    本文根据Python 3.6.5的官文Built-in Exceptions编写,不会很详细,仅对Python的内置异常进行简单(重难点)介绍——很多异常都可以从名称判断出其意义,罗列所有的内置异常. ...

随机推荐

  1. ubuntu14.04 anaconda tensorflow spyder(python3.5) + opencv3

    windows上用的tensorflow是依赖于python3.5,因此在linux下也配的3.5 一. 在Anaconda官网上下载Anaconda3-4.0.0-Linux-x86_64.sh文件 ...

  2. Spring框架[一]——spring概念和ioc入门(ioc操作xml配置文件)

    Spring概念 spring是开源的轻量级框架(即不需要依赖其他东西,可用直接使用) spring核心主要两部分 aop:面向切面编程,扩展功能不是修改源代码来实现: ioc:控制反转,比如:有一个 ...

  3. oracle 11 g release 2 安装

    1.下载Oracle 11g R2 for Windows版本 下载地址如下官方网站: http://www.oracle.com/technetwork/database/enterprise-ed ...

  4. [easyUI] lazyload 懒加载

    1.使用<img>标签将图片都写在网页上. <div style="height:450px;"><h1>请往下看,有图片的吆!</h1& ...

  5. 雷林鹏分享:jQuery EasyUI 数据网格 - 使用虚拟滚动视图显示海量数据

    jQuery EasyUI 数据网格 - 使用虚拟滚动视图显示海量数据 数据网格(datagrid)的虚拟滚动特性可以用来显示大数量的记录而不需要分页. 当滚动垂直滚动条时,数据网格(datagrid ...

  6. 异步核心接口IAsyncResult的实现

    要实现异步编程,就需要正确的实现IAsyncResult接口.IAsyncResult共有四个属性: public interface IAsyncResult { object AsyncState ...

  7. SQL SERVER 事务的使用(tran)

    sql server事务的使用是为了确保数据的一致性. 通常写法 begin tran --sql 语句1 --sql 语句2 --sql 语句3 commit tran 上面写法存在隐患,当操作(增 ...

  8. oracle导出大数据

    Sqluldr是什么:是一个oracle数据导出小工具. Sqluldr作用介绍:Sqluldr可以快速导出oracle数据库中的数据.该小工具可以将数据库中的数据,导出多种不同的格式(如.txt.. ...

  9. CF 3-6 2级组 D题 STRESSFUL TRAINING 紧张的比赛

    题目大概是这样的: 给出一个数列a[n] ,对于每一个数 a [i] 来说 都会在 T - - 时 -= b[i] 每个数都在任何时刻不能小于0 你可以在每次T - - 之前时给 一 个 a[i] + ...

  10. 【C/C++】小坑们

    1.printf("%03d", a); // 输出 a,占 3 位,不够则左边用 0 填充 2.memcpy 所在头文件为 <string.h> 3.string s ...