Pythonic way to create a long multi-line string

后端 未结 27 1642
滥情空心
滥情空心 2020-11-22 00:47

I have a very long query. I would like to split it in several lines in Python. A way to do it in JavaScript would be using several sentences and joining them with a +<

27条回答
  •  北海茫月
    2020-11-22 00:56

    Breaking lines by \ works for me. Here is an example:

    longStr = "This is a very long string " \
            "that I wrote to help somebody " \
            "who had a question about " \
            "writing long strings in Python"
    

提交回复
热议问题