相关疑难解决方法(0)

如何编写符合PEP8的非常长的字符串并阻止E501

由于PEP8建议保持低于你的python程序的80列规则,我怎么能遵守长字符串,即

s = "this is my really, really, really, really, really, really, really long string that I'd like to shorten."
Run Code Online (Sandbox Code Playgroud)

我将如何将其扩展到以下行,即

s = "this is my really, really, really, really, really, really" + 
    "really long string that I'd like to shorten."
Run Code Online (Sandbox Code Playgroud)

python string pep8

182
推荐指数
5
解决办法
6万
查看次数

Python,PEP-8,E122延续线缺少缩进或缩进

我得到了这个错误但是我选择缩进它,我仍然得到它,你知道为什么吗?

if len(argmaxcomp) == 1:
    print "The complex with the greatest mean abundance is: {0}"\
    .format(argmaxcomp[0])
Run Code Online (Sandbox Code Playgroud)

python pep8

6
推荐指数
2
解决办法
2万
查看次数

Python字符串文字串联

我可以使用以下语法创建多行字符串:

string = str("Some chars "
         "Some more chars")
Run Code Online (Sandbox Code Playgroud)

这将产生以下字符串:

"Some chars Some more chars"
Run Code Online (Sandbox Code Playgroud)

Python是加入这两个单独的字符串还是编辑器/编译器将它们视为单个字符串?

Ps:我只想了解内部情况.我知道还有其他方法来声明或创建多行字符串.

python string python-2.7 python-internals

6
推荐指数
1
解决办法
4137
查看次数

标签 统计

python ×3

pep8 ×2

string ×2

python-2.7 ×1

python-internals ×1