How to write multiple strings in one line?

后端 未结 11 655
谎友^
谎友^ 2020-12-01 03:28

I\'ve started to learn Python with LPTHW and I\'ve gotten to exercise 16:

http://learnpythonthehardway.org/book/ex16.html

And feel like an idiot because I ca

11条回答
  •  半阙折子戏
    2020-12-01 03:38

    The author suggested using the formats, the strings and the escapes, so the following works. This implements Python's f-strings:

    target.write(f"{line1} \n{line2} \n{line3} \n")
    

提交回复
热议问题