- 假设我有以下字符串:
I love to eat apple and
bananas but at the same time, I do
not like to eat oranges
and I am not a fan of vegetables.
I also like to eat biscuits.
Meanwhile, oddly enough, I have never liked
ice creams or chocolates because I
am never a sweet-toothed.
- 因此,我如何将多行字符串组合成一行?也就是说,我将得到以下结果:
I love to eat apple and bananas but at the same time, I do not like to eat oranges and I am not a fan of vegetables.
I also like to eat biscuits.
Meanwhile, oddly enough, I have never liked ice creams or chocolates because I am never a sweet-toothed.
我对正则表达式还很陌生,因此我不确定如何处理这个案例。
2条答案
按热度按时间7z5jn7bk1#
欢迎使用
re
!按如下方式使用sub
模块:ecfdbz9o2#
简单的
str.split
可能就足够了:图纸: