python - 如何打破 PEP8 合规性的长字符串?

标签 python string pep8

我在项目中有很多这样的长行,不知道如何打破它以保持 PEP8 快乐。 PEP8 显示来自 .format(me['id'])

的警告
pic_url = "http://graph.facebook.com/{0}/picture?width=100&height=100".format(me['id'])

我怎样才能断行以摆脱 PEP8 警告但又不破坏代码?

最佳答案

使用 string literal concatenation :

pic_url = ("http://graph.facebook.com/{0}/"
           "picture?width=100&height=100".format(me['id']))

关于python - 如何打破 PEP8 合规性的长字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25949525/

相关文章:

python - 在 Python 2.6.5 中,是否有可以用于 urllib.quote 和 urllib.unquote 的 unicode 替代品?

python - 使用来自用户的 url 的服务器端 urllib2.urlopen 的安全注意事项

r - 列出 R 中数据帧中的所有不同字符串

python - 将一行 "if else"语句分成多行

Python JSON 序列化一个 Decimal 对象

actionscript - 删除 ActionScript 2 变量中的空格

mysql - 是否可以将 varchar 限制为 MySQL 中的特定字符集?

python - 如何修复 flake 8 错误 "E712 comparison to False should be ' 如果 cond 为 False :' or ' 如果不是 cond :'"在 pandas dataframe

python - 为什么我们有 lower_case_with_underscores 命名约定?

python - 在 matplotlib 中,为什么用细线绘图会更快?