Discuss / Python / 字符串筛选拼接

字符串筛选拼接

Topic source

SenSibility7

#1 Created at ... [Delete] [Delete and Lock User]

运用字符串拼接,通过for循环将输入字符串中非空格字符筛选出来,与一个空字符串拼接,然后返回该字符串即可 def trim(s): L='' for i in range(len(s)): if s[i]!=' ': L=L+s[i] return L


  • 1

Reply