如何缩进多行字符串的内容? [英] How to indent the contents of a multi-line string?

查看:87
本文介绍了如何缩进多行字符串的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python cog 模块生成C ++样板代码,并且运行良好,因此到目前为止,但我唯一担心的是,由于代码本身没有缩进,因此导致代码本身很丑陋,因此变得更糟.我懒得在字符串生成函数中获得缩进,所以我想知道是否有Python util函数来缩进多行字符串的内容?

I'm using the python cog module to generate C++ boilerplate code, and it is working great so far, but my only concern is that the resulting code, which is ugly by itself, is made worse by the fact that it's not indented. I'm too lazy to get the indentation right in the string generation function, so I'm wondering if there is a Python util function to indent the content of a multi-line string?

推荐答案

为什么不通过诸如astyle之类的命令行代码格式化程序通过管道传递输出?

Why not pipe the output through a command-line code formatter such as astyle?

这篇关于如何缩进多行字符串的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆