TypeError:' int'对象不是可下载的Python 3.4.2

时间:2015-02-11 23:35:20

标签: python python-3.x

我想在Python 3.4.2中编写一个代码,它接受一串数字,将它们分开,然后按相反的顺序排列。到目前为止,我有:

#input string
numberIntegers = 123456
#assign each character to an idex
zeroDigit = numberIntegers[0]
oneDigit = numberIntegers[1]
secondDigit = numberIntegers[2]
thirdDigit = numberIntegers[3]
fourthDigit = numberIntegers[4]
fifthDigit = numberIntegers[5]
print(" The numbers to reverse:  {}".format(numberIntegers))
print(" The digits, in order, are: {} {} {} {} {} {}".format(zeroDigit,oneDigit,secondDigit,thirdDigit,fourthDigit,fifthDigit))
print(" The numbers in reverse: ")

1 个答案:

答案 0 :(得分:0)

numberIntegers是一个整数而不是一个字符串。像这样改变:

numberIntegers = '123456'