开发者社区> 问答> 正文

python3.* 不换行输出语法提示报错,但是能正确打印,大家有同样的问题吗??报错

比如代码如下:

x="hello"
y="world"


print(x , end = " ")
print(y)

eclipse 就会提示“Syntax error while detecting tuple.”

但是执行能正确执行,大家有碰到这样的问题吗?

展开
收起
爱吃鱼的程序员 2020-06-22 18:28:27 352 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    去确认了一下,python3的print的语法:

    http://docs.python.org/3.0/library/functions.html#print

    • print([object,...][,sep=''][,end='\n'][,file=sys.stdout])

      Printobject(s)tothestreamfile,separatedbysepandfollowedbyend.sep,endandfile,ifpresent,mustbegivenaskeywordarguments.

      Allnon-keywordargumentsareconvertedtostringslike str()doesandwrittentothestream,separatedby sepandfollowedby end.Both sepand endmustbestrings;theycanalsobe None,whichmeanstousethedefaultvalues.Ifno objectisgiven, print()willjustwrite end.

      Thefileargumentmustbeanobjectwithawrite(string)method;ifitisnotpresentorNone, sys.stdoutwillbeused.


    所以,你的写法,应该没错才对。

    推测:

    估计你是用的Eclipse(中的pyDev)所用的python语法,用的别的版本的(python2.x)的?

    所以:

    你自己去确认一下,你的Eclipse中耳朵(PyDev)的python语法,用的是哪个版本。


    2020-06-22 18:28:45
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载