How to print list items which contain new line?

后端 未结 4 719
感动是毒
感动是毒 2021-01-29 12:07

These commands:

l = [\"1\\n2\"]    
print(l)

print

[\'1\\n2\']

I want to print

[\'1
2\']
         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-29 12:30

    Try this:

    s = ["1\n2"]
    print("['{}']".format(s[0]))
    => ['1
       2']
    

提交回复
热议问题