2024-09-26 22:13:20 发布
网友
在Python3.2中,我可以做到:
foo = Bar() foo.setSomething(something1).setStatus('horizontal').setAttributes(attributes)
最后链条变得相当长。我渴望一条垂直的铁链。你知道吗
foo = Bar() foo.setSomething(something1) .setStatus('vertical') .setAttributes(attributes)
有什么办法吗?你知道吗
感谢@Krotton的回答,它确实有效。还要感谢@sean的link。因此,使用垂直链接的正确方法是:
foo = Bar() (foo.setSomething(something1) .setStatus('vertical') .setAttributes(attributes))
您还可以使用语法(如多行字符串)来允许垂直链接:
foo = Bar() foo.setSomething(something1)\ .setStatus('vertical')\ .setAttributes(attributes)
只需将表达式括在括号中:
感谢@Krotton的回答,它确实有效。还要感谢@sean的link。因此,使用垂直链接的正确方法是:
您还可以使用语法(如多行字符串)来允许垂直链接:
只需将表达式括在括号中:
相关问题 更多 >
编程相关推荐