官方文档
学习地址
http://docs.python.org/3/library/functions.html#abs
Help(命令)
D:\PythonProject>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> help(abs)
Help on built-in function abs in module __builtin__:
abs(...)
abs(number) -> number
Return the absolute value of the argument.
>>>
常用函数
abs() 取绝对值
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 函数调用
# abs()
a = abs(-100)
print(a)
运行结果
D:\PythonProject>python run.py
100
max() 取最大值
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 函数调用
# max()
a = max(1,2,3,4,5)
print(a)
运行结果
D:\PythonProject>python run.py
5
类型转换
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 函数调用
# 类型转换
# int()字符串转数字
x = int("1")
print(x)
# str()数字转字符串
x = str(1)
print(x)
# 布尔型转换
x = bool(1)
print(x)
# 非 1 为 False
x = bool(0)
print(x)
运行结果
D:\PythonProject>python run.py
1
1
True
False