擅长:python、mysql、java
<p>请尝试以下方法为整个范围而不是仅为一行生成字符串</p>
<pre><code>def __str__(self):
content = []
for i in range(9):
if (i + 1)%3 != 0:
content.append(self.grille[i].occupe + ' | ')
else:
content.append(self.grille[i].occupe)
return '\n'.join(content)
</code></pre>