[英]Pep8 E501: line too long error
I get the error E501: line too long
from this code: 我从这段代码得到错误
E501: line too long
:
header, response = client.request('https://api.twitter.com/1.1/statuses /user_timeline.json?include_entities=true&screen_name='+username+'&count=1')
but if I write this way or another way: 但如果我这样写或以其他方式写:
header, response = client.request('\
https://api.twitter.com/1.1/statuses/user_timeline.\
json?include_entities=true&screen_name='+username+'&count=1')
I get this error: 我收到此错误:
ValueError: Unsupported URL https://api.twitter.com/1.1/statuses/user_timeline .json?include_entities=true&screen_name=username&count=1 ().
or I get this error: 或者我收到此错误:
ValueError: No JSON object could be decoded
So please tell me, how can I pass this error? 所以请告诉我,我怎么能传递这个错误?
The whitespaces at the beginning of the lines become part of your string if you break it like this. 如果你像这样打破它,那么行开头的空格就会成为你字符串的一部分。
Try this: 试试这个:
header, response = client.request(
'https://api.twitter.com/1.1/statuses/user_timeline.'
'json?include_entities=true&screen_name=' + username + '&count=1')
The strings will automatically be concatenated . 字符串将自动连接 。
You could also go to into the code analysis and ignore that kind or error/warning. 您还可以进入代码分析并忽略该类型或错误/警告。 I am using eclipse and Pydev.
我正在使用eclipse和Pydev。
Windows > Preferences > Pydev > Editor > Code Analysis > pycodestyle.py (pep8)
then add to arguments : --ignore=E501
Restart Eclipse and it should be fine for this warning. 重新启动Eclipse,这个警告应该没问题。
You could build the string on multiple lines: 您可以在多行上构建字符串:
st='https://api.twitter.com/1.1/statuses/user_timeline.json?'
st=st+'include_entities=true&screen_name='+username+'&count=1'
header, response = client.request(st)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.