03 python -数字 math

本文介绍了Python中数字类型的转换以及math模块的使用。通过`import math`导入math模块后,可以使用如`acos`, `sin`, `log`等数学函数。此外,还涵盖了math模块中的三角函数和随机函数。" 132547330,19694724,C++中使用boost::rethrow_exception的示例解析,"['C/C++', '异常处理', 'boost库']
摘要由CSDN通过智能技术生成

数字类型转换

int(x [,base ])         将x转换为一个整数  
long(x [,base ])        将x转换为一个长整数  
float(x )               将x转换到一个浮点数  
complex(real [,imag ]) 创建一个复数  
str(x )                 将对象 x 转换为字符串 string 
repr(x )                将对象 x 转换为表达式字符串  
eval(str )#用来计算在字符串中的有效Python表达式,并返回一个对象  
tuple(s )  #将序列 s 转换为一个元组  
list(s )   #将序列 s 转换为一个列表  
chr(x )   #将一个整数转换为一个字符  char c c++中字符和字符串 a b c ‘a’ “asfdsfs” 

python math块

1、导入
import math
2、查看math中包含的内容
dir(math)
[‘doc‘, ‘file‘, ‘loader‘, ‘name‘, ‘package‘, ‘spec‘, ‘acos’, ‘acosh’, ‘asin’, ‘asinh’, ‘atan’, ‘atan2’, ‘atanh’, ‘ceil’, ‘copysign’, ‘cos’, ‘cosh’, ‘degrees’, ‘e’, ‘erf’, ‘erfc’, ‘exp’, ‘expm1’, ‘fabs’, ‘factorial’, ‘floor’, ‘fmod’, ‘frexp’, ‘fsum’, ‘gamma’, ‘gcd’, ‘hypot’, ‘inf’, ‘isclose’, ‘isfinite’, ‘isinf’, ‘isnan’, ‘ldexp

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值