4 读取用户指令

1.语法

python 复制代码
input()  

2.示例

python 复制代码
#要求手动输入信息,打印信息卡  
Please input your name:xxx  
Please input your age:xxx  
Your hobbie:xxx  
  
----------xxx info----------  
name:xxx  
age:xxx  
hobbie:xxx  
-------------end-------------  
  
  
#实现代码  
name = input("Please input your name:")  
age = input("Please input your age:")  
hobbie = input("Your hobbie:")  
  
msg = f'''  
----------{name} info----------  
name:{name}  
age:{age}  
hobbie:{hobbie}  
-------------end-------------  
'''  
print(msg)  
相关推荐
Warson_L1 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅1 天前
海天线算法的前世今生
python·计算机视觉
韩师傅1 天前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L1 天前
LangGraph的MessageState and HumanMessage
python
韩师傅1 天前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L1 天前
python的类&继承
python
Warson_L1 天前
类型标注/type annotation
python
ThreeS1 天前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵1 天前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏