我的整个代码如下(不想错过任何东西)。出于某种原因,我不断收到一个错误,我无法将浮点数转换为整数?
import math
def getRange(input):
if (1 <= input < 10):
return [1,1,9]
elif (10 <= input < 190):
return [2,10,99]
elif (190 <= input < 2890):
return [3,100,999]
elif (2890 <= input < 38890):
return [4,1000,9999]
elif (38890 <= input < 488890):
return [5,10000,99999]
elif (488890 <= input < 5888889):
return [6,100000,999999]
def getDigit(input):
workingRange=getRange(input)
multi_digit_dec = ((input-workingRange[1])/workingRange[0])+workingRange[1]
multi_digit_float = math.floor((input-workingRange[1])/workingRange[0])+workingRange[1]
print multi_digit_float
multi_digit_int = input(multi_digit_float)
decimal_remainder = multi_digit_int - multi_digit_dec
## digit_id = decimal_remainder * len(str(multi_digit_int))
## actual_digit = str(multi_digit_dec)[digit_id]
## return actual_digit
getDigit(100)
我的错误是:
Traceback (most recent call last):
File "C:\Users\Samuel\Desktop\Python\concatenate string of variables and product values.py", line 29, in <module>
getDigit(100)
File "C:\Users\Samuel\Desktop\Python\concatenate string of variables and product values.py", line 22, in getDigit
multi_digit_int = int(multi_digit_float)
TypeError: 'int' object is not callable
>>>
上面更新的代码以反映称为 int 的变量的变化以输入