Skip to content

Commit d968506

Browse files
committed
feat: string split connect
1 parent b31814a commit d968506

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 要求
2+
# 1.将字符串中的空白字符全部去掉
3+
# 2.再使用 " " 作为分隔符,拼接成一个整齐的字符串
4+
poem_str = "\n登鹳雀楼\t 王之涣 \t 白日依山尽 \t \n 黄河入海流 \t\t 欲穷千里目 \n\n 更上一层楼"
5+
print(poem_str)
6+
7+
# 1.拆分字符串
8+
poem_list = poem_str.split()
9+
print(poem_list)
10+
11+
# 2.合并字符串
12+
print(" ".join(poem_list))

0 commit comments

Comments
 (0)