How to format raw string with different expressions inside?

前端 未结 2 557
甜味超标
甜味超标 2020-12-09 11:26

Let\'s say, we want to catch something with regex, using rawstring to define the pattern, which pattern has repeating elements, and variables inside. And we also want to use

2条回答
  •  情深已故
    2020-12-09 11:50

    Use f-strings (introduced in Python 3.6):

    a = 15
    print(fr'Escape is here:\n but still {a}')
    
    # => Escape is here:\n but still 15
    

提交回复
热议问题