码迷,mamicode.com
首页 > 编程语言 > 详细

python习题12

时间:2018-11-15 22:28:05      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:uil   ted   available   highlight   class   stand   用法   marked   doc   

ex12

1 age = input("How old are you?")
2 height = input("How tall are you?")
3 weight = input("How much do you weight?")
4 
5 print(f"So,you‘re {age} old, {height} tall and {weight} heavy.")

 

在终端上键入python -m pydoc input

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.

 

*pydoc命令的用法(目前看不懂)

1. python -m pydoc input:查看纯文本帮助信息,类似于函数的帮助说明。

  (纯文本帮助)

2. python -m pydoc atexit :在当前目录创建atexit.html 

    python -m pydoc -p 5000 :启动一个web服务器监听 http://localhost:500/

  (html帮助)

3. pydoc还为__builtins__添加了一个函数help(),从而可以在解释器窗口访问同样的信息。

  (交互式帮助)(看不懂)

 

*python open() 函数用于打开一个文件,创建一个 file 对象,相关的方法才可以调用它进行读写。

 

连在一起试试看

1 age = int(input("How old are you?"))
2 height = int(input(f"I knew you are {age} old.How tall are you?"))
3 weight = input("How much do you weight?")
4 
5 print(f"So,you‘re {age} old, {height} tall and {weight} heavy.")

 

python习题12

标签:uil   ted   available   highlight   class   stand   用法   marked   doc   

原文地址:https://www.cnblogs.com/shadowyuriya/p/9966053.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!