3- 基础数据类型、数据类型转换

noteId: 2400764FB8324532BB7DE8D0A1D63FBF · 原始路径:/ALL/Python、Flask - vscode/python 基础命令用法/3- 基础数据类型、数据类型转换.note

Python数据类型:

整数(int) //int() 浮点数(float) //float()字符串(string) //str()布尔值(bool) //bool()列表(list) //list()元组(tuple) //tuple()字典(dictionary) //dict()集合(set) //set()

数据类型转换:

a = 123b = '123'print (type (a),type(b))a = str(a) # 转换为字符串类型b = list(b) # 转换为列表类型print (type(a),type(b))# 输出结果:<class 'int'> <class 'str'>

<class 'str'> <class 'list'>a = str(a) # 永久转换print (type(list(b))) # 临时转换print (type(a),type(b))# 输出结果:<class 'list'>

<class 'str'> <class 'str'>