为什么语法错误?

为什么是这样:
# other stuff...
print str(checksum)+" "+ranswer+".0000000000"
在Python 3中给出语法错误,即使它在Python 2.5中工作正常吗? 添加: 谁能告诉我在python 3中
strip(something)
的等价物是什么? 谢谢,现在修好了。     
已邀请:
print是Python3中的一个函数。使用它是
print(...)
没有任何叫做
strip(something)
的东西。但你可能要寻找的是字符串对象上的`strip()方法。它在Python3中可用。
strip(...)
    S.strip([chars]) -> str

    Return a copy of the string S with leading and trailing
    whitespace removed.
    If chars is given and not None, remove characters in chars instead.
你这样使用它:
>>> '   Philando Gullible   '.strip()
'Philando Gullible'
>>> 'aaaXXXbbb'.strip('ab')
'XXX'
    
在Python 3中,print是一个函数,而不是关键字。 这样做:
print(str(checksum)+" "+ranswer+".0000000000")
    

要回复问题请先登录注册