📜  int 对象在 python 代码示例中不可下标

📅  最后修改于: 2022-03-11 14:45:04.609000             🧑  作者: Mango

代码示例1
"""
This error means the variable you want to subscript is an integer.

if you want to subscript an int, a way of doing that is turning it to str.
"""
num = 1234
x = num[2]  # does not work
x = int(str(num)[2])  # works, x = 3