A first attempt:
l = ["1
2"]
print(repr(l).replace('\n', '
'))
The solution above doesn't work in tricky cases, for example if the string is "1\n2"
it replaces, but it shouldn't. Here is how to fix it:
import re
l = ["1
2"]
print(re.sub(r'\n|(\.)', lambda match: match.group(1) or '
', repr(l)))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…