Cod*_*987 -3 python python-3.x
这是python的新手,试试这个 -
def newlines():
print()
print()
print()
question = "Which online Course you have signed up, dude?"
response = "Good Luck to you, dude!"
print(question), newlines(), input(), newlines(), print(response)
Run Code Online (Sandbox Code Playgroud)
在Python 3.2.*中输出就是这个
Which online Course you have signed up, dude?
Nothing
Good Luck to you, dude!
(None, None, "Nothing", None) # Where this output is coming from ?
Run Code Online (Sandbox Code Playgroud)
python 3.3 beta也没有发生这种情况
您必须在交互式shell中.当我将代码作为文件运行时,我得到了这个输出:
$ python3.2 test.py
Which online Course you have signed up, dude?
dlkjdf
Good Luck to you, dude!
$
Run Code Online (Sandbox Code Playgroud)
您只能在控制台获得输出:
>>> def newlines():
... print()
... print()
... print()
...
>>> question = "Which online Course you have signed up, dude?"
>>> response = "Good Luck to you, dude!"
>>>
>>> print(question), newlines(), input(), newlines(), print(response)
Which online Course you have signed up, dude?
dljdldk
Good Luck to you, dude!
(None, None, 'dljdldk', None, None)
>>>
Run Code Online (Sandbox Code Playgroud)
这是因为控制台将打印您输入的最后一个内容的表示.最后一个语句实际上是一个元组,因此它最后会打印出来.以下是一些例子:
>>> 3
3
>>> 4
4
>>> 3, 4, None, "hey"
(3, 4, None, 'hey')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
108 次 |
| 最近记录: |