腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
Python
while
_
ValueError
summation = 0 user_input = input("Enter your input \n") print("End \n", "SUMMATION = ", summation) Enter you
浏览 14
提问于2021-11-09
得票数 0
2
回答
为什么
Python
代码要生成
ValueError
?
这是我的代码:
while
num1 < 0 or not isinstance(num1 , int):= int(input("Enter a positive integer: "))
while
num2 = float(input("Enter a decimal be
浏览 3
提问于2015-12-15
得票数 1
回答已采纳
4
回答
错误捕获字符串和整数
") try: break print("Please
浏览 7
提问于2016-12-29
得票数 0
回答已采纳
2
回答
在
python
中获取安全的用户输入
、
、
我只想要一个整数,并偶然发现(我认为是)一段很好的代码,类似于(从内存中执行此操作):
while
True: try: except
ValueError
: print "please enter a number事实证明,我使用的是
python
< 3,作者为3+编写了这段代码。所以现在我不得不重写2.7版本来满足我的需求。但是我如
浏览 0
提问于2013-07-20
得票数 2
回答已采纳
4
回答
如何使用户在
Python
程序中只输入整数值
、
、
我有一项作业,我很困惑。我必须编写一个程序,允许用户输入他们正在购买的鸡蛋的数量。然后,该程序将告诉他们有多少盒子(6个鸡蛋),他们可以填补和有多少鸡蛋是剩余的。
浏览 9
提问于2014-02-26
得票数 1
回答已采纳
3
回答
除了
ValueError
之外的
Python
:
While
True
、
、
、
我尝试使用'
while
true‘来要求用户输入0或一个正整数。我尝试了几种不同的方法,它们似乎都有不同的问题。函数def positive_int拒绝字母和负整数,但不允许阶乘函数工作。def positive_int(prompt=''): try: raise
ValueError
break
浏览 12
提问于2020-04-27
得票数 0
回答已采纳
2
回答
Python
输入/字符串
(
Python
2.7.10)所以我是
python
的初学者,大约一周前才开始学习。在编写第3行和第5行注释的代码时,我需要一些帮助。
浏览 5
提问于2015-11-14
得票数 1
回答已采纳
2
回答
在
Python
3中引发异常后返回到特定点
、
、
、
、
mainfile.write(str('Grade Average: ') + str(average) + '\n') raise
ValueError
except
ValueError
as AverageError: print
浏览 3
提问于2014-03-30
得票数 0
回答已采纳
2
回答
Python
请求十进制数
、
谁能告诉我如何让代码要求一个值(例如用户将输入100.00),并将该数字与它的2个小数点的值放在后面的更多函数,即:乘以它,等等。
浏览 5
提问于2011-03-03
得票数 0
回答已采纳
2
回答
Python
:检测输入错误以及如何提供解决方案
我是
python
的初学者,做了几个程序,我看到的一个相同的事情是,当我写一个像这样的do = int(input("Enter number >"))代码时,我不小心输入了一个字母,我希望能够给出一个错误的输入消息,然后再试一次,但是
python
总是能检测到变量容器中的差异。
浏览 2
提问于2020-05-09
得票数 0
1
回答
检查第一个循环的第二个循环。
、
while
(integer_check == False): integer = int(input(" :")) else:
while
(integer < 0) and (integer_check =
浏览 1
提问于2019-10-07
得票数 0
回答已采纳
2
回答
创建输入整数函数
、
py_version = find_version() response = input(question) return int(response) response = raw_input(question) try: return int(resp
浏览 0
提问于2015-12-12
得票数 3
回答已采纳
3
回答
如何在一个异常块中检查多个异常?
、
、
try: number = filex.readline().rstrip('\n')
while
number) print(added) if IOError: prin
浏览 0
提问于2020-01-14
得票数 0
1
回答
python
的新手遇到了不受支持的操作数类型的问题?
谢谢m = "hi"
while
len(key) < 0: print("Please enter a key")
浏览 1
提问于2015-10-13
得票数 0
回答已采纳
2
回答
我可以使用
while
循环来限制用户变量吗?
import random>>>
while
True: user
浏览 6
提问于2017-07-26
得票数 0
回答已采纳
2
回答
用户输入接受str和int (
python
)
noAdults = input("Please enter the number of adults:") print("NumbernoAdults < 0: noAdults = input("Please enter the number of adults:")我猜想有一个<em
浏览 4
提问于2014-05-06
得票数 0
回答已采纳
1
回答
*不支持的操作数类型:'NoneType‘和'NoneType’(
Python
)
(我是菜鸟)
while
True: number = int(input("Number: "))break print("NOPE...")def multiply(x,y): print(z) x = userinput() y = userinput
浏览 0
提问于2013-09-15
得票数 2
回答已采纳
3
回答
捕获输入验证中的错误
import sys newamount=int(input('Enter the new amount:')) print ("error
浏览 0
提问于2013-10-24
得票数 2
回答已采纳
2
回答
如何使用循环将数字相加?
、
、
、
def adding(): x = 0
while
x !
浏览 1
提问于2014-03-24
得票数 0
2
回答
Python
简单数比较
、
、
、
random user = raw_input('> ')
while
浏览 4
提问于2013-09-25
得票数 1
回答已采纳
点击加载更多
相关
资讯
Python天坑:while 1比while True更快?
Python While 循环语句
Python的while循环
Python天坑:while 1比while True 更快?
Python-while循环
热门
标签
更多标签
云服务器
ICP备案
对象存储
云点播
即时通信 IM
活动推荐
运营活动
广告
关闭
领券