python习题12

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.")

 

posted @ 2018-11-15 21:03  yuriya  阅读(231)  评论(0编辑  收藏  举报