摘要: # -*- coding: utf-8 -*- # 请使用迭代查找一个list中最小和最大值,并返回一个tuple from collections import Iterable def findMinAndMax(L): if len(L) == 0: return (None,None) if 阅读全文
posted @ 2019-10-29 15:25 it_逗逗 阅读(1196) 评论(0) 推荐(0) 编辑
摘要: 方法一: # -*- coding: utf-8 -*- # 利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法: def trim(s): while s[:1] == ' ': s = s[1:] while s[-1:] == ' ': s = 阅读全文
posted @ 2019-10-29 12:38 it_逗逗 阅读(1433) 评论(0) 推荐(0) 编辑