Python Code One Line Length 80 Characters Limited

Asked 2 years ago, Updated 2 years ago, 24 views

As I use pylint, if the length of one line is more than 80 characters, it bothers me to keep underlining, so I am trying to write it so that the length of the code is not as long as possible. And then suddenly

HEADER = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"
}
driver.find_element_by_css_selector("body > div.ReactModalPortal > div > div > div > div > div.contentsBox > span.btnBox > span:nth-child(2)").click()

I'm writing because I'm curious about what to do if one string is longer than 80 characters, as in the above two cases... In this case, do you not bother to touch one long string? If not, which part and how should I split it?

Or are there many people who don't care about the 80 character limit? I'm curious...!

python

2022-09-21 12:14

1 Answers

It can be expressed as below.

In other words, you can cut the long lines appropriately and tie them together as shown below, and separate them into \.

In [9]: 'aaaaa''bbbbb'                                                          
Out[9]: 'aaaaabbbbb'

In [10]: print ('very long string' 
    ...: 'Second String')                                                       
Very long string Second string


2022-09-21 12:14

If you have any answers or tips


© 2025 OneMinuteCode. All rights reserved.