第一种:
利用str()函数将数字转化成字符串,再利用len()函数判断位长。
1 a=Int(raw_input("the number you want type in:") 2 b=len(str(a)) 3 print b
第二种:
利用除10取商,通过循环次数判断位数。
1 c=0 2 a=int(raw_input("the number you want type in:")) 3 while a!=0: 4 a=a/10 5 c +=1 6 print c
第一种:
利用str()函数将数字转化成字符串,再利用len()函数判断位长。
1 a=Int(raw_input("the number you want type in:") 2 b=len(str(a)) 3 print b
第二种:
利用除10取商,通过循环次数判断位数。
1 c=0 2 a=int(raw_input("the number you want type in:")) 3 while a!=0: 4 a=a/10 5 c +=1 6 print c
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。