Discuss / Python / 1

夏哲宇zg

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

def trim(s): length = len(s) for i in range(length-1): for j in range(1,length): if s[i] != ' ' and s[-j] != ' ': s = s[i:-j] return s

s = str(input('请输入:')) print(trim(s))


  • 1

Reply