すべての文字列がlenで等しくなるように、文字列のタプルにスペースを挿入する関数があります。また、文字列のタプルといくつかの書式設定情報を取得し、それらを文字列の 1 つのタプルに結合する関数もあります。
#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
値を変数に格納しようとしましたが、何も変わりませんでした。おそらく単純なものですが、私には見えません。