2022年6月4日

python实现list元素倒叙

摘要: def revList(lis): a = len(lis) if a > 1: b = a//2 for i in range(b): lis[i], lis[a-1-i] = lis[a-1-i], lis[i] #print(lis) return lis 阅读全文

posted @ 2022-06-04 02:44 Darren-Frank 阅读(137) 评论(0) 推荐(0)

python实现句子倒叙,且保留原始空格数

摘要: """完成一个句子的倒叙,单词中的字母顺序不变输入: 输出:1 1’ 1‘ ’1 ‘..."""def revers_str(str_old): l_s = list(str_old) #string 转list a = len(l_s) newStr = '' newTab = '' newLis 阅读全文

posted @ 2022-06-04 02:17 Darren-Frank 阅读(99) 评论(0) 推荐(0)

导航