![ced13d3a92efa393349f765d6ddd016b.png](https://img-blog.csdnimg.cn/img_convert/ced13d3a92efa393349f765d6ddd016b.png)
笨方法”学Python3,习题 12:提示别人
1、如何在input函数中提示别人?
一、基础代码
所写的代码:
age = input("How old are you? ")
height = input("How tall are you? ")
weight = input("How much do you weigh? ")
print(f"So, you are {age} old, {height} tall and {weight} heavy.")
---------------------------------------------------------------------------------------------------
应该看到的结果:
PS D:代码> & D:/软件/python/python.exe d:/代码/ex12.py
How old are you? 19
How tall are you? 197
How much do you weigh? 167
So, you are 19 old, 197 tall and 167 heavy.
![2860ee2aff3e9c0887b3fc5ecf2efe05.png](https://img-blog.csdnimg.cn/img_convert/2860ee2aff3e9c0887b3fc5ecf2efe05.png)
二、巩固练习
1、在终端用pydoc查找input函数(终端就是平时输出结果的地方)
pydoc是python自带的一个文档生成工具,使用pydoc可以很方便的查看类和方法结构
PS D:代码> python -m pydoc input
Help on built-in function input in module builtins:
input(prompt=None, /)
Read a string from standard input. The trailing newline is stripped.
The prompt string, if given, is printed to standard output without a
trailing newline before reading input.
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
On *nix systems, readline is used if available.
![395feb5a4413ee7b3e0e8d0ec9f4e119.png](https://img-blog.csdnimg.cn/img_convert/395feb5a4413ee7b3e0e8d0ec9f4e119.png)
总结:
1、input函数可以提示别人,通过在括号里写入字符串达到效果
2、pydoc可以查找函数的用法
^ v ^,知乎此系列文章内容均会在微信公众号中同步更新,公众号:小民有个小旮旯