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. linux 因内存不足而 kill 掉 java 程序

    grep "Out of memory" /var/log/messages Sep 17 16:13:34 xxxaaa kernel: Out of memory: Kill ...

  2. MySQL 5.6容器使用自定义配置文件的权限问题

    提出问题: 在使用Rancher2.0.2部署一个mysql deployment时,我们会发现,如果只设置/var/lib/mysql数据目录时,mysql容器(pod)能够正常启动,一旦数据目录和 ...

  3. 整理this笔记

    1.在浏览器全局环境中this指向的是Window console.log(this); //Window 2.在事件处理函数中的this,这个事件是由谁触发,this就指向谁 3.直接执行一个函数的 ...

  4. 一个时代的终结:为什么是时候放弃ITOM四大巨头了?这对IT领导者来说意味着什么?

    ​​关注嘉为科技,获取运维新知 2018年7月,Broadcom宣布了收购CA Technologies的计划,收购额近190亿美元.虽然分析师对于芯片制造商收购企业级软件公司这件事是否值得还在进行激 ...

  5. xxx征集系统项目目标文档

    分组:每四人一组 主题:xxx征集系统 成果: 讨论结束后,每组提交一份课堂讨论记录(电子版发表到博客上,纸质版小组成员签名,下节课提交). 每人根据课堂讨论结果提交一份系统利益相关者描述案例.撰写项 ...

  6. restore not found的错误

    tensorflow保存模型后,restore的时候报参数not found是什么原因呢 一般预测的流程是:建图然后restore参数,很有可能你的变量作用域和train的时候不一样,那么在现在的变量 ...

  7. 牛客网多校第3场C-shuffle card 平衡树或stl(rope)

    链接:https://www.nowcoder.com/acm/contest/141/C 来源:牛客网 题目描述 Eddy likes to play cards game since there ...

  8. C++11 boost TR1 TR2曾经参考过的网址整理

    boost::bind的用法:http://blog.csdn.net/adcxf/article/details/3970116

  9. <转载> 从算法上解读自动驾驶是如何实现的?

     科技新闻小鹏汽车2016-03-28 10:42 [摘要]车辆路径规划问题中路网模型.路径规划算法和交通信息的智能预测为关键点. 由于驾驶员的驾驶工作繁重,同时随着汽车拥有量的增加,非职业驾驶员的数 ...

  10. day050 django第一天 自定义框架

    1.简单的web框架 1. 创建一个简单的python文件: import socket sever=socket.socket() sever.bind(('127.0.0.1',8001)) se ...