如何更换 或者 在 python2.7

问题描述 投票:0回答:1

如何更换 或者 在 在 Python 2.7 中?

输入字符串 = '你好 世界 '
输出字符串 = '你好 世界 '

python python-2.7
1个回答
0
投票

你可以使用

str.replace()
方法。 不过我不确定你的 python 版本...

Input_string = 'hello\r\n\n world\n \r\r\n\r\n'
Output_string = Input_string.replace('\n', '\r\n').replace('\r', '\r\n')
© www.soinside.com 2019 - 2024. All rights reserved.