>>> import math
>>> math.pi 3.141592653589793
>>> dir(math) ['__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
>>> help(math.pow)
Help on built-in function pow in module math: pow(...) pow(x, y) Return x**y (x to the power of y).
>>> 4**2 16 >>> math.pow(4,2) 16.0 >>> 4*2 8
>>> math.sqrt(9) 3.0 >>> math.floor(3.14) 3.0 >>> math.floor(3.92) 3.0 >>> math.fabs(-2) # 等价于 abs(-2) 2.0 >>> abs(-2) 2 >>> math.fmod(5,3) # 等价于 5%3 2.0 >>> 5%3 2
>>> abs(10) 10 >>> abs(-10) 10 >>> abs(-1.2) 1.2
>>> round(1.234) 1.0 >>> round(1.234,2) 1.23 >>> # 如果不清楚这个函数的用法,可以使用下面方法看帮助信息 >>> help(round)
Help on built-in function round in module __builtin__: round(...) round(number[, ndigits]) -> floating point number Round a number to a given precision in decimal digits (default 0 digits). This always returns a floating point number. Precision may be negative.
| [center]运算符[/center] | [center]描述[/center] |
|---|---|
| lambda | Lambda 表达式 |
| or | 布尔“或” |
| and | 布尔“与” |
| not x | 布尔“非” |
| in,not in | 成员测试 |
| is,is not | 同一性测试 |
| <,<=,>,>=,!=,== | 比较 |
| | | 按位或 |
| ^ | 按位异或 |
| & | 按位与 |
| <<,>> | 移位 |
| +,- | 加法与减法 |
| *,/,% | 乘法、除法与取余 |
| +x,-x | 正负号 |
| ~x | 按位翻转 |
| ** | 指数 |
| x.attribute | 属性参考 |
| x[index] | 下标 |
| x[index:index] | 寻址段 |
| f(arguments...) | 函数调用 |
| (experession,...) | 绑定或元组显示 |
| [expression,...] | 列表显示 |
| {key:datum,...} | 字典显示 |
| 'expression,...' | 字符串转换 |
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-3 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.yuanmawang.com) 版权所有