How to declare a long string in Python?

前端 未结 4 1200
生来不讨喜
生来不讨喜 2020-12-04 19:06

I have a really long string in python:

long_string = \'
this is a really
really
really
long
string
\'

However, since the string spans multi

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 20:01

    You can use either

    long_string = 'fooo' \
    'this is really long' \
    'string'
    

    or if you need linebreaks

    long_string_that_has_linebreaks = '''foo
    this is really long
    '''
    

提交回复
热议问题