#!/usr/bin/evc python
# -*- coding:utf-8 -*-
# 获取对象的内存地址
str1 = "123"
print(id(str1))
# 判定变量属于何种类型-type()
temp = "hey"
print(type(temp))
temp1 = 12
print(type(temp1))
temp2 = 12.00
print(type(temp2))
temp3 = True
print(type(temp3))
temp4 = ["hello", 12, '54.0']
print(type(temp4))
temp5 = ("hello", 12, '54.0')
print(type(temp5))
temp6 = {"name": "hello", "age": 12, "score": '54.0'}
print(type(temp6))
# 绝对值
i = abs(-123)
print(i)
# 0,None,"" -> 假的。all()用于判断迭代类型的元素是否都为真,都为真返回真。类似于and连接
print(all([1 + 1, 2, "3", 1]))
# any()用于判断迭代类型的元素,只要有1个为真,就可认为为真,类似于or连接
print(any([1 + 1, 0, None, ""]))
# 将值转化为二进制
print(bin(100))
# 将值转化为八进制
print(oct(9))
# 将值转化为十进制
print(int(66))
# 将值转化为十六进制
print(hex(15))
# 将二进制转化为十进制
print(int('0b11', base=2))
# 将八进制转化为
Python中可用到的内置函数
最新推荐文章于 2021-03-11 21:13:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)