print sep=''在Python 2.7.8中不工作

2024-09-27 00:15:33 发布

您现在位置:Python中文网/ 问答频道 /正文

作为试用,我在Python2.7.8中使用了以下代码:

print 'one', 'two', 'three', sep =''

我得到的信息是

SyntaxError: invalid syntax

我想要的结果是

onetwothree


Tags: 代码信息onesepthreeprintsyntaxtwo
1条回答
网友
1楼 · 发布于 2024-09-27 00:15:33

print()函数是Python3的一个特性,但是您可以像这样在Python2上获得它

>>> from __future__ import print_function
>>> print('one', 'two', 'three', sep='')
onetwothree

相关问题 更多 >

    热门问题