如何使 Python 中的模板符合 PEP8 标准?

How to make template in Python PEP8 compliant?

我似乎无法找到一种方法在不破坏我的项目的情况下将以下代码行分解为多行以符合 79 个字符的限制。

这些是断章取义的,但我在 Python 中的 HTML 模板中使用了它们 3. 我进行了大量搜索以找到答案,但找不到找到它处理 Python 文件内部的 HTML 而不是 Python 代码本身的情况。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<link href="https://fonts.googleapis.com/css?family=Roboto:500|Source+Sans+Pro" rel="stylesheet">

$('.modal').html('<iframe id="ytplayer" type="text/html" src="https://www.youtube.com/embed/' + trailer + '?autoplay=1" frameborder="0" allowfullscreen></iframe>');

谢谢!

PEP8 是指南而非标准。也就是说,您在 HTML 中编码,而不是 Python,因此 python 风格指南不适用。

最后,

For code maintained exclusively or primarily by a team that can reach agreement on this issue, it is okay to increase the nominal line length from 80 to 100 characters.

如果您确实需要,可以根据您使用的模板系统将每个字符串保存为变量,然后在脚本或 link 行中使用该变量。