蟒蛇拆分字符串在换行并保留换行

问题描述:

有没有办法将包含换行符的字符串拆分成保留换行符的字符串列表,例如:蟒蛇拆分字符串在换行并保留换行

"amount\nexceeds" 

会产生

["amount\n", "exceeds"] 

使用splitlines(),传递true:

"amount\nexceeds".splitlines(True) 

为您提供:

["amount\n", "exceeds"]