Python3:使用 input() 和 textwrap() 在文本后打印 space
Python3: Printing a space after a text using input() and textwrap()
我输入了一行打印字符串的代码,紧接着,它打印了用户输入。
名称=输入(textwrap.fill("Gerald: Hello adventurer, what is thy name?: ",宽度=42))
^
它不是打印这个 space。
我希望它打印出 space 的结果。
...what is thy name?: 冒险者的名字
^
冒号后带有 space。
这应该有效
import textwrap
Name = input(textwrap.fill("Gerald: Hello adventurer, what is thy name?: ", width=42, drop_whitespace=False))
来源:https://docs.python.org/3.5/library/textwrap.html#textwrap.TextWrapper.drop_whitespace
我输入了一行打印字符串的代码,紧接着,它打印了用户输入。
名称=输入(textwrap.fill("Gerald: Hello adventurer, what is thy name?: ",宽度=42)) ^ 它不是打印这个 space。 我希望它打印出 space 的结果。 ...what is thy name?: 冒险者的名字 ^ 冒号后带有 space。
这应该有效
import textwrap
Name = input(textwrap.fill("Gerald: Hello adventurer, what is thy name?: ", width=42, drop_whitespace=False))
来源:https://docs.python.org/3.5/library/textwrap.html#textwrap.TextWrapper.drop_whitespace