Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python ValueError中计算器类型程序出错_Python - Fatal编程技术网

python ValueError中计算器类型程序出错

python ValueError中计算器类型程序出错,python,Python,这是我的脚本,我是python新手,但我是来理解这一点的,请原谅我的回答,并记住我是新手 import functools numbers=[] def means(): end_mean = functools.reduce(lambda x, y: x + y, numbers) / len(numbers) print(end_mean) def sum(): end_sum = functools.reduce(lambda x, y: x + y, numb

这是我的脚本,我是python新手,但我是来理解这一点的,请原谅我的回答,并记住我是新手

import functools
numbers=[]

def means():
    end_mean = functools.reduce(lambda x, y: x + y, numbers) / len(numbers)
    print(end_mean)

def sum():
    end_sum = functools.reduce(lambda x, y: x + y, numbers)
    print(end_sum)

def whatDo():
        print('Input Extra Numbers '+str(len(numbers)+1)+' (or nothing to close):')
        try:
            number= int(input())
            numbers.append(number)
        except:
            print('What do you want to do?')
            answer = input()
            if answer == "mean":
                means()

while True:
    print('Input Number '+str(len(numbers)+1)+' (or nothing to close):')
    try:
        number= int(input())
        numbers.append(number)
    except:
        print('What do you want to do?')
        answer = input()
        if answer == "mean":
            means()
            print('Do you want anything else?')
            reply=input()
            if reply=='no':
                break
            elif reply--'yes':
                whatDo()
        else:
            break
但我得到的是:

Traceback (most recent call last):
  File "E:/Python/calculator.py", line 26, in <module>
    number= int(input())
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:/Python/calculator.py", line 37, in <module>
    elif reply--'yes':
TypeError: bad operand type for unary -: 'str'
回溯(最近一次呼叫最后一次):
文件“E:/Python/calculator.py”,第26行,在
number=int(输入())
ValueError:基数为10的int()的文本无效:“”
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“E:/Python/calculator.py”,第37行,在
以利夫回答“是”:
TypeError:一元操作数的操作数类型错误-:“str”
在“你还想要什么”之后,我输入“是”。

elif-reply--“是”:
应该是
elif-reply=='yes':
elif-reply--'yes':
应该是
elif-reply=='yes':
你有打字错误

elif reply--'yes'
当然应该是这样

elif reply=='yes'
你打错了

elif reply--'yes'
当然应该是这样

elif reply=='yes'

问题很清楚:
reply=='yes'
问题很清楚:
reply=='yes'