2024-04-24 16:03:29 发布
网友
我应该在代码中做些什么来避免类型错误?在
n=5 print("*"*n) for i in range(n-2,0,-2): print(" "*((n-i)/2)+"*"*i)
*TypeError: can't multiply sequence by non-int of type 'float'*
字符串乘法需要整数值:
n=5 print("*" * n) for i in range(n-2,0,-2): print(" " * ((n-i) // 2) + "*" * i)
你的问题是:
print(" "*((n-i)/2)+"*"*i)
{cd1>你有一个浮点数。如果将其重新解释为整数,则可以:
字符串乘法需要整数值:
你的问题是:
{cd1>你有一个浮点数。如果将其重新解释为整数,则可以:
^{pr2}$相关问题 更多 >
编程相关推荐