我有一个函数,它将在字符串元组中插入空格,以便所有字符串的len相等。我还有一个函数,可以处理字符串元组和一些格式化信息,并将它们组合为一个字符串元组
#code for equal string length
def insertSpace(self,content):
max = 0
for string in content:
temp = len(string)
if temp > max:
max=temp
retstring = ("",)
for string in content:
retstring = retstring + (" "*(max - len(string)+1,)
return self.combine(retstring,content,bold=False,newline=False)
#code for combine
def combine(self,leftside,rightside,bold=False,newline=False):
if bold is True:
bold = '<B>'
boldend = '</B>'
else:
bold = ''
boldend = ''
if newline is True:
newlinechar = '<br>'
else:
newlinechar = ''
return tuple((bold +"{0}"+boldend+"{1}"+newlinechar).format(x,y) for x,y in zip(leftside,rightside))
执行此脚本会导致
File "mypythonfile.py", line 108
return self.combine(retstring,content,bold=False,newline=False)
^
SyntaxError: invalid syntax
我试图将值存储在变量中,但没有任何改变。大概有点简单,但我看不到。
12345678_0001
相关分类