python-3.x - 输入函数后的行未执行
问题描述
我正处于 python 的最初阶段。当我试图通过打印语句打印我输入的值时,它不起作用。我的输入没有结束,它取值但不会进入下一行的打印语句。
def addition(A,B):
return A+b
Value1 = input("Enter the Value1:")
print(Value1)
解决方案
您需要调用您的函数并整理变量名称,因为它们不同且不符合 PEP8。最终的工作版本将是:
def addition(a,b):
return a+b
value1 = int(input("Enter the Value1:")) # The reason I call int here is input() returns a string.
value2 = int(input("Enter the Value2:"))
print(addition(value1, value2)
推荐阅读
- windows-10 - Windows 10,默认禁用 EnhancedPowerManagementEnabled
- c - Couchbase C API 不再有 n1ql.h 了吗?
- typescript - 如何从联合类型的集合中获取正确键入的项目?
- java - Java 简单日期格式化程序显示错误值
- javascript - VSCode 仅在某处导入时通过相应的 Foo.d.ts 为 Foo.js 提供智能感知;如何在 Foo.js 本身中启用智能感知?
- android - Ionic 5 应用程序在闪屏后卡在白屏上
- python - 熊猫:如何从同一列但不同的行填写值
- amazon-web-services - Golang AWS Firehose 使用 json 字段名称而不是结构字段名称
- spring-webflux - 如何在spring webflux中使用对象映射器以非阻塞方式将对象转换为映射
- amazon-web-services - 为什么 AWS 中的 NLB 不需要安全组?