上一页 1 ··· 325 326 327 328 329 330 331 332 333 ··· 375 下一页
摘要: 1、 >>> a = ["aaa","bbb","aaa","aaa","bbb","aaa","ccc","ddd","ddd"] >>> b = [] >>> for i in a: if i not in b: b.append(i) >>> b ## for循环去重复 ['aaa', 'bb 阅读全文
posted @ 2021-02-24 21:59 小鲨鱼2018 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = ["aaa","bbb","ccc","ddd"] >>> b = ["ccc","ddd","eee","fff"] >>> c = [] >>> for i in a: if i not in b: c.append(i) >>> c ['aaa', 'bbb'] >>> 阅读全文
posted @ 2021-02-24 21:45 小鲨鱼2018 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = ["aaa","bbb","ccc","ddd"] >>> b = ["ccc","ddd","eee","fff"] >>> c = a + b >>> c ['aaa', 'bbb', 'ccc', 'ddd', 'ccc', 'ddd', &# 阅读全文
posted @ 2021-02-24 21:38 小鲨鱼2018 阅读(1180) 评论(0) 推荐(0) 编辑
摘要: >>> a = ["aa","bb","aa","cc","aa","dd","bb","aa","cc"] >>> a ['aa', 'bb', 'aa', 'cc', 'aa', 'dd', 'bb', 'aa', 'cc'] > 阅读全文
posted @ 2021-02-24 10:51 小鲨鱼2018 阅读(2456) 评论(0) 推荐(0) 编辑
摘要: >>> sum = 0 >>> for i in range(1,101): ## 利用for循环 sum += i >>> print(sum) 5050 >>> del sum >>> sum(list(range(1,101))) ## 利用sum函数 5050 >>> sum = 0 >>> 阅读全文
posted @ 2021-02-24 10:44 小鲨鱼2018 阅读(3347) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = [20,10,50,40,30] >>> max = a[0] >>> for i in a: if i > max: max = i >>> print(max) 50 >>> min = a[0] >>> for i in a: if i < min: min = i >> 阅读全文
posted @ 2021-02-24 10:37 小鲨鱼2018 阅读(675) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = ["cc","aa","bb","cc","aa","dd","aa","cc","ee","dd"] >>> sorted(set(a)) ['aa', 'bb', 'cc', 'dd', 'ee'] >>> b = sorted(set(a 阅读全文
posted @ 2021-02-24 10:19 小鲨鱼2018 阅读(346) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = [34,28,187,22,128] >>> max = a[0] >>> for i in a: ## 求最大值 if i > max: max = i >>> print(max) 187 >>> min = a[0] >>> for i in a: ## 求最小值 if 阅读全文
posted @ 2021-02-24 10:11 小鲨鱼2018 阅读(5155) 评论(0) 推荐(0) 编辑
摘要: >>> a = ["aa","aa","bb","cc","bb","aa","dd","cc","aa","aa","aa"] >>> a ['aa', 'aa', 'bb', 'cc', 'bb', 'aa', 'dd', &# 阅读全文
posted @ 2021-02-24 09:58 小鲨鱼2018 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = [] >>> b = ["aa","bb","cc"] >>> if len(a) == 0: print("empty!") empty! >>> if len(b) == 0: print("empty!") 2、 >>> a = ["aa","bb","cc","dd"] 阅读全文
posted @ 2021-02-24 09:37 小鲨鱼2018 阅读(4597) 评论(0) 推荐(0) 编辑
上一页 1 ··· 325 326 327 328 329 330 331 332 333 ··· 375 下一页