Discuss / Python / 数据类型转换

数据类型转换

Topic source

沐__秋

#1 Created at ... [Delete] [Delete and Lock User]

“如int()函数可以把其他数据类型转换为整数”,准确的说其他数据类型指数字、字节对象(如True)或字符串。字符串好像只能是整数的字符串??

如int("1.23")会报错:

>>int('1.23')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.23'

  • 1

Reply