How can I do a line break (line continuation) in Python?

后端 未结 11 1584
囚心锁ツ
囚心锁ツ 2020-11-21 22:56

I have a long line of code that I want to break up among multiple lines. What do I use and what is the syntax?

For example, adding a bunch of strings,



        
11条回答
  •  感情败类
    2020-11-21 23:50

    You can break lines in between parenthesises and braces. Additionally, you can append the backslash character \ to a line to explicitly break it:

    x = (tuples_first_value,
         second_value)
    y = 1 + \
        2
    

提交回复
热议问题