标签: python split newline delimiter
有没有办法将包含换行符的字符串拆分为保留换行符的字符串列表,例如
"amount\nexceeds"
会产生
["amount\n", "exceeds"]
答案 0 :(得分:8)
使用splitlines(),传递True:
splitlines()
"amount\nexceeds".splitlines(True)
给你: