Python在一条语句中获取多个输入的代码

【代码一:eval(input())】
eval(input()) 的多个输入用逗号分隔。

python 复制代码
x,y,z=eval(input()) #Enter numbers separated by commas
sum=x+y+z
print(sum)

'''
in:
1,2,3

out:
6
'''

【代码二:map(int,input().split())
map(int,input().split()) 的多个输入用空格分隔。

python 复制代码
x,y,z=map(int,input().split()) #Enter numbers separated by space
sum=x+y+z
print(sum)

'''
in:
1 2 3

out:
6
'''
相关推荐
耶夫斯计6 分钟前
【SQL_agent】基于LLM实现sql助理
数据库·python·sql·语言模型
vibag7 分钟前
RAG向量数据库
python·语言模型·langchain·大模型
kisshuan123967 分钟前
基于YOLO11改进的C3k2-AdditiveBlock实现命中检测与双重命中事件识别_1
python
mg6688 分钟前
0基础开发学习python工具_____用 Python + Pygame 打造绚丽烟花秀 轻松上手体验
开发语言·python·学习·pygame
nervermore99018 分钟前
2.6 测试
python
EZ_Python26 分钟前
告别WPS会员!用Python自制电子发票批量打印排版工具
python·自动化
写文章的大米28 分钟前
1 分钟读懂:Python 装饰器
python
2501_9216494934 分钟前
股指期货 API 入门指南:如何获取实时行情与构建交易系统
python·websocket·金融·区块链·restful
Full Stack Developme1 小时前
Spring Security 与 Apache Shiro 两大安全框架比较
spring boot·python·安全
杰瑞哥哥1 小时前
快速搭建Web前端(streamlit使用指南)
python·信息可视化·web·模型部署