小编Nay*_*eto的帖子

使用python计算输入的位数

我正在尝试计算输入的位数。但是,每当我输入1011或任何两位数时,输出都是325. 为什么不起作用?

inputnumber = int(input())
countnumber = inputnumber
digitcount = 0
while countnumber > 0:
    digitcount += 1
    countnumber = countnumber/10

print(digitcount) 
# result is 325 when input is 10 or 11
Run Code Online (Sandbox Code Playgroud)

python decimal digits division python-3.x

4
推荐指数
1
解决办法
2435
查看次数

标签 统计

decimal ×1

digits ×1

division ×1

python ×1

python-3.x ×1