Pep8 E501: line too long error

前端 未结 3 2247
说谎
说谎 2021-01-04 05:26

I get the error E501: line too long from this code:

header, response = client.request(\'https://api.twitter.com/1.1/statuses   /user_timeline.js         


        
相关标签:
3条回答
  • 2021-01-04 06:12

    You could also go to into the code analysis and ignore that kind or error/warning. I am using eclipse and 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.

    0 讨论(0)
  • 2021-01-04 06:12

    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)
    
    0 讨论(0)
  • 2021-01-04 06:21

    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.

    0 讨论(0)
提交回复
热议问题