Python 如何在控制台上的打印语句附近打印return语句的结果?

Python 如何在控制台上的打印语句附近打印return语句的结果?,python,Python,我有必要在控制台上打印一个句子,并在句子附近打印返回语句的结果。这是一个例子: print("Le stringhe sono vuote") return None 这是函数的一段代码。 这超出了功能范围: print(function([...])) 结果是: 如何绕过新行?如果您使用的是Python 3.x: from __future__ import print_function print("Le stringhe sono vuote", end="") 默认情况下,pyt

我有必要在控制台上打印一个句子,并在句子附近打印返回语句的结果。这是一个例子:

print("Le stringhe sono vuote")
return None
这是函数的一段代码。 这超出了功能范围:

print(function([...]))
结果是:


如何绕过新行?

如果您使用的是Python 3.x:

from __future__ import print_function
print("Le stringhe sono vuote", end="")
默认情况下,python的print()函数以换行符结尾。蟒蛇的 print()函数附带一个名为“end”的参数。默认情况下 此参数的值为“\n”,即新行字符。你可以 使用此参数以任何字符/字符串结束打印语句

Python 2.6.0a2及更高版本

from __future__ import print_function
print("Le stringhe sono vuote", end="")

为什么不返回一个concatated val:

return ("Le stringhe sono vuote", None)
我怎样才能绕过这条新线路

您可以将
end=”“
传递到
print()


也许考虑接受你以前提出的问题的答案?
print("Le stringhe sono vuote", end = "")
print(function([...]), end="")