python 中print函数实现输出不换行

 

001、

[root@pc1 test3]# python2       ## python2
Python 2.7.5 (default, Jun 28 2022, 15:30:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("xxx", end = "")     ## 报错
  File "<stdin>", line 1
    print("xxx", end = "")
                     ^
SyntaxError: invalid syntax

 

 

002、python3

[root@pc1 test3]# python3    ### python3
Python 3.9.12 (main, Apr  5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("xxx", end = "")    ## 输出不换行
xxx>>>

 

posted @ 2022-11-03 15:51  小鲨鱼2018  阅读(105)  评论(0)    收藏  举报