python - 如何在一行中输入多个值?
问题描述
如何在一行中输入多个值?输出应类似于 a:8 b:5 c:6 d:4 e:0.1
我试过这个输入:
a, b, c, d, e = int(input(' '.format(a:, b:, c:, d:, e:)))
但这没有用。
解决方案
你可以这样做:
a, b, c, d, e = input("Insert the 5 values: ").split()
print(f"a: {a}\nb: {b}\nc: {c}\nd: {d}\ne: {e}")
输入:
1 2 3 4 5
输出:
a: 1
b: 2
c: 3
d: 4
e: 5
推荐阅读
- flutter - 如何去除脚手架中的晶圆厂底部填充物
- nginx - 动态位置块变量到字符串
- python - 如何使用python从动态网页中收集表格数据
- spring-boot - 如何在 Spring Boot 项目的某些模块上配置自定义 Pitest Gradle 任务?
- ios - 为什么 ViewController 后退按钮在 Xcode 上不起作用?
- python - 在python中获取下一个12个月的最大值
- bash - AWS localstack 和 dotnetcore3.1 lambda 函数 - 无法创建函数
- vuejs2 - Vue 计算属性改变存储状态
- javascript - [Vue 警告]:无效的道具:道具“已禁用”的类型检查失败。预期布尔值,得到函数
- python - sagemaker 项目模板部署从哪里获取环境变量