译自:https://learnxinyminutes.com/docs/python3/
阅前须知:
- “#”后边的是注释
- 带行号的是python代码
- 不带行号的是代码的输出
- 把下边的语句对着敲一边自然就会了,博主用的是jupyter notebook
1 2 3
| import math print(math.sqrt(16))
|
4.0
1 2 3 4
| from math import ceil, floor print(ceil(3.7)) print(floor(3.7))
|
4
3
1 2 3
| import math as m math.sqrt(16) == m.sqrt(16)
|
True
1 2 3 4 5
|
import 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',
'lgamma',
'log',
'log10',
'log1p',
'log2',
'modf',
'nan',
'pi',
'pow',
'radians',
'sin',
'sinh',
'sqrt',
'tan',
'tanh',
'tau',
'trunc']