|
|
发表于 2020-4-1 01:37:27
|
显示全部楼层
本帖最后由 cug_cui 于 2020-4-1 01:40 编辑
1.end=" "的问题。
在idle中输入help(print),可以查看print()函数文档。函数有默认参数,其中一个end='\n',表示打印完内容会自动换行。end='' " 表示打印完加一个空格,从而不会换行。
- >>> help(print)
- Help on built-in function print in module builtins:
- print(...)
- print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
-
- Prints the values to a stream, or to sys.stdout by default.
- Optional keyword arguments:
- file: a file-like object (stream); defaults to the current sys.stdout.
- sep: string inserted between values, default a space.
- end: string appended after the last value, default a newline.
- flush: whether to forcibly flush the stream.
复制代码
2.input问题。
同样查询input。input的括号内可以加提示符(语),也可以不加,默认为空(prompt=None)。
input改在while循环里是为了实现3次机会,猜错了可以再次输入。
input函数的作用是读入一个字符串。
- >>> help(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.
- >>>
复制代码
3.“那又怎么知道()代表是输入哪里?”这句话不知道想问什么。
|
|