import re
word = """关关雎鸠,在河之洲。
窈窕淑女,君子 好逑。
参差荇菜,左右 流之。
窈窕淑女,寤寐求之。
求之不得,寤寐思服。
悠哉悠哉,辗转 反侧。
参差荇菜,左右采之。
窈窕淑女,琴瑟友之。
参差荇菜,左右 芼之。
窈窕淑女,钟鼓乐之。"""
new_word = "".join((re.sub("\n", " ", word)).split(" "))
print(new_word)
demo = ["1",2,3,4,"5"]
def list_str(list):
s_word = ""
if len(list) != 0:
while True:
if isinstance(list[0],int):
s_word+=str(list[0])
list.remove(list[0])
else:
s_word += list[0]
list.remove(list[0])
if len(list) == 0:
break
else:
return "该列表为空"
return s_word
print(list_str(demo))
ret= demo.replace(" ","")