Skip to main content
 首页 » 编程设计

python之int() 参数必须是字符串或数字,而不是 'builtin_function_or_method'之python

2025年05月04日23softidea

回溯说:

Traceback (most recent call last): 
  File "dex.py", line 37, in <module> 
    n=int(raw_input) 
TypeError: int() argument must be a string or a number, not 'builtin_function_or_method' 

和代码:

t[n]=1 

其中 t 是 t=[0, 0, 0, 0, 0, 0, 0, 0, 0 ,0] n 是 int(raw_input)

我基本上想做的是将 t 的索引 n 设置为 int(raw_input)。

请您参考如下方法:

raw_input 是一个函数,您需要调用它并将该调用的结果传递给 int():

n = int(raw_input())