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
'''
相关推荐
少林码僧1 天前
2.31 机器学习神器项目实战:如何在真实项目中应用XGBoost等算法
人工智能·python·算法·机器学习·ai·数据挖掘
智航GIS1 天前
10.4 Selenium:Web 自动化测试框架
前端·python·selenium·测试工具
jarreyer1 天前
摄像头相关记录
python
宝贝儿好1 天前
【强化学习】第六章:无模型控制:在轨MC控制、在轨时序差分学习(Sarsa)、离轨学习(Q-learning)
人工智能·python·深度学习·学习·机器学习·机器人
大、男人1 天前
python之asynccontextmanager学习
开发语言·python·学习
默默前行的虫虫1 天前
nicegui文件上传归纳
python
一个没有本领的人1 天前
UIU-Net运行记录
python
国强_dev1 天前
Python 的“非直接原因”报错
开发语言·python
副露のmagic1 天前
更弱智的算法学习 day24
python·学习·算法
廖圣平1 天前
从零开始,福袋直播间脚本研究【三】《多进程执行selenium》
python·selenium·测试工具