我怎样才能修复“TypeError:无法将'int'对象转换为str隐式”?

时间:2014-10-02 04:03:18

标签: python

我试图编写一段代码来制作数字字典。这是代码:

inp = input('name of file?\n')
x = input('starting number?\n')
y = input('ending number?\n')
dic = open(inp, 'w')
while  x <= y:
    dic.write(x)
    x += 1

一旦我运行它:

user@babas:~/script$ python3 numgen.py 
name of file?
test file
starting number?
1
ending number?
9
Traceback (most recent call last):
  File "numgen.py", line 12, in <module>
    x += 1
TypeError: Can't convert 'int' object to str implicitly

我尝试在Google上寻找一些答案,但无法解决任何问题。

0 个答案:

没有答案