【发布时间】:2015-01-22 17:04:16
【问题描述】:
我在 cdef 类(Cython 语言)中有以下代码:
def toString(self):
res = "lut= " + str(self._mm_np[0].lut) +
"n1= " + str(self._mm_np[0].n1) +
"nlay= "+ str(self._mm_np[0].nlay) +
"n3= " + str(self._mm_np[0].n3)
return res
当我尝试编译包含此代码的 cython 文件时,我收到以下语法错误: “预期的标识符或文字”指向字符串连接中的第一个“+”。
我尝试使用'\'而不是'+'但没有成功.. 在 Pyhton/Cython 中连接字符串的正确方法是什么? 谢谢!
【问题讨论】: