python - TypeError:'int'对象不可调用python3但没有round()或sum()函数
问题描述
目前正在尝试创建一个程序,该程序在给定用户输入的位数的情况下生成一个数字,但是,它有时会在用户的数字选择下生成。我创建了一个 if 条件来检查这一点,但它给了我以下错误:
TypeError: 'int' object is not callable
到目前为止,这是我的python3代码......
# To generate number with certain amount of digits by user input as a list:
import random as gen
digit_count = int(input('Enter number of digits: '))
def function():
max = int('9' * digit_count)
number = gen.randint(0, max)
check = len(str(abs(number)))
if check != digit_count:
print(number)
function()
else:
print(number)
print(max)
function()
解决方案
推荐阅读
- python - 预期类型'None',改为'str',python pandas
- python - Python输入和随机系统
- python - Tkinter 消息框中的编辑按钮
- javascript - 如何为我的 javascript 启用 Youtube API
- vba - 如果在用户表单 excel VBA 中禁用,则启用所有命令按钮
- github - Github:拥有一个无法检索秘密的维护者
- python - 以正确的方式使用天气数据对时间序列进行上采样
- python - 在 Anaconda-(JUPYTER NOTEBOOK) OPENPYXL 无法正常工作
- python - 从 pd DataFrame 获取最接近的日期时间索引值
- c++ - 这是一个简单的 C++ 程序,用于查找 DAG 中的路径数量,但我收到 SIGSEGV 错误?