【详细】Python数据类型转换

 时间:2026-02-15 16:52:12

1、str(x),将元素 x 转换为字符串

【详细】Python数据类型转换

2、tuple(s),将序列 s 转换成元组

>>> tuple([2,3,4,5])

(2, 3, 4, 5)

【详细】Python数据类型转换

3、list(s),将序列 s 转换成列表

>>> a = (123,'123','abc')

>>> list(a)

[123, '123', 'abc']

【详细】Python数据类型转换

4、chr(x),将整数(ASCII码)转换为字符

【详细】Python数据类型转换

5、hex(x),将整数转换为十六进制字符串

【详细】Python数据类型转换

6、oct(x),将整数转换为一个八进制字符串

【详细】Python数据类型转换

  • 如何利用excel分别求取一个三位数各个数位的值
  • list index out of range错误解决方法
  • python怎么导入excel数据
  • can only concatenate str (not "int") to str
  • 【Python】replace() 函数
  • 热门搜索
    羊台山攻略 减肥零食 老中医减肥茶 帝国时代2攻略 wps格式刷怎么用 减肥明星 吞食天地3攻略 塞纳怎么样 怎么表白成功率高 萧军简介