相关疑难解决方法(0)

在没有Python空格的情况下打破长字符串

所以,这是我的代码片段:

return "a Parallelogram with side lengths {} and {}, and interior angle 
{}".format(str(self.base), str(self.side), str(self.theta)) 
Run Code Online (Sandbox Code Playgroud)

它超越了80个字符,在一条线上有良好的造型,所以我这样做:

return "a Parallelogram with side lengths {} and {}, and interior angle\
{}".format(str(self.base), str(self.side), str(self.theta)) 
Run Code Online (Sandbox Code Playgroud)

我添加了"\"来分解字符串,但是当我打印它时会出现这个巨大的空白间隙.

如何在不扭曲代码的情况下拆分代码?

谢谢!

python string

7
推荐指数
1
解决办法
2067
查看次数

标签 统计

python ×1

string ×1