小编Joe*_*Joe的帖子

TypeError:'str'对象不能解释为整数

我不明白代码的问题是什么,它非常简单,所以这很简单.

x = input("Give starting number: ")
y = input("Give ending number: ")

for i in range(x,y):
 print(i)
Run Code Online (Sandbox Code Playgroud)

它给了我一个错误

Traceback (most recent call last):
  File "C:/Python33/harj4.py", line 6, in <module>
    for i in range(x,y):
TypeError: 'str' object cannot be interpreted as an integer
Run Code Online (Sandbox Code Playgroud)

例如,如果x为3且y为14,我希望它打印

Give starting number: 4
Give ending number: 13
4
5
6
7
8
9
10
11
12
13
Run Code Online (Sandbox Code Playgroud)

问题是什么?

python types

9
推荐指数
3
解决办法
9万
查看次数

标签 统计

python ×1

types ×1