📅  最后修改于: 2022-03-11 14:46:59.207000             🧑  作者: Mango
# Python code to remove newline character from string using replace() method
text = "A regular \n expression is a sequence \n of characters\n that specifies a search\n pattern. "
print(text.replace('\n', ''))
my_list = ["Python\n", "is\n", "Fun\n"]
new_list = []
print("Original List: ", my_list)
for i in my_list:
new_list.append(i.replace("\n", ""))
print("After removal of new line ", new_list)