摘要:
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 阅读全文
摘要:
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'] >>> 阅读全文
摘要:
1、 >>> a = ["aaa","bbb","ccc","ddd"] >>> b = ["ccc","ddd","eee","fff"] >>> c = a + b >>> c ['aaa', 'bbb', 'ccc', 'ddd', 'ccc', 'ddd', 阅读全文
摘要:
>>> a = ["aa","bb","aa","cc","aa","dd","bb","aa","cc"] >>> a ['aa', 'bb', 'aa', 'cc', 'aa', 'dd', 'bb', 'aa', 'cc'] > 阅读全文
摘要:
>>> 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 >>> 阅读全文
摘要:
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 >> 阅读全文
摘要:
1、 >>> a = ["cc","aa","bb","cc","aa","dd","aa","cc","ee","dd"] >>> sorted(set(a)) ['aa', 'bb', 'cc', 'dd', 'ee'] >>> b = sorted(set(a 阅读全文
摘要:
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 阅读全文
摘要:
>>> a = ["aa","aa","bb","cc","bb","aa","dd","cc","aa","aa","aa"] >>> a ['aa', 'aa', 'bb', 'cc', 'bb', 'aa', 'dd', 阅读全文
摘要:
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"] 阅读全文