zoukankan      html  css  js  c++  java
  • 内置函数一

    1.abs(5)#返回绝对值

    2.all()#所有为真返回true,为假返回false

    3.any()#其中一个为真就返回true

    4.bin()#返回二进制形式

    5.bool()#为真返回 true,为假返回false

    6.callable()#若为可执行返回 true,反之返回false

    7.chr()#将数字转换为字母

    8. ord()#将assic字符转化为数字

    9.divmod()#取整除及余数

    10.enumerate()#改变起始数据序列

    for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter'],start=1):
    print i, season
    1 Spring
    2 Summer
    3 Fall
    4 Winter
    11.dir()#查看对像内所有属于及方法

    12.compile(source, filename, mode[, flags[, dont_inherit]])

    中文说明:将source编译为代码或者AST对象。代码对象能够通过exec语句来执行或者eval()进行求值。

    参数source:字符串或者AST(Abstract Syntax Trees)对象。

    参数 filename:代码文件名称,如果不是从文件读取代码则传递一些可辨认的值。

    参数model:指定编译代码的种类。可以指定为 ‘exec’,’eval’,’single’。

    13.eval()#将字符串当成有效Python表达式来求值,并返回计算结果

    eg:

    x = 1
    res=eval('x+1')
    print (res)
     
  • 相关阅读:
    OAuth
    PHP获取客户端的真实IP
    负载均衡----实现配置篇(Nginx)
    在线时间戳转换
    使用curl进行模拟登录
    定时任务
    Matplotlib使用教程
    CentOS7.X安装PHP
    Python虚拟环境的搭建与使用
    CentOS7.X安装openssl
  • 原文地址:https://www.cnblogs.com/guisheng/p/6063900.html
Copyright © 2011-2022 走看看