摘要:
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"] 阅读全文
摘要:
>>> import random >>> random.randint(1,10) ## 随机抽取1-10的数字 1 >>> random.randint(1,10) 4 >>> random.randint(1,10) 9 >>> random.randint(1,100) 67 >>> ran 阅读全文
摘要:
>>> a = ["aa","bb","cc","aa","dd","ee","aa","aa","ff","aa"] >>> a ['aa', 'bb', 'cc', 'aa', 'dd', 'ee', 'aa', 'aa', 阅读全文
摘要:
>>> a = ["aa","bb","cc","dd","ee"] >>> a ['aa', 'bb', 'cc', 'dd', 'ee'] >>> "aa" in a True >>> "dd" in a True >>> "aa" not in a False & 阅读全文
摘要:
1、 >>> a = ["aa","bb","cc","dd","ee"] >>> temp = a[1] ## 引入变量 >>> temp 'bb' >>> a[1] = a[3] >>> a ['aa', 'dd', 'cc', 'dd', 'ee'] >>> a[3] = temp > 阅读全文
摘要:
>>> a = ["ee","cc","aa","ff","aa","cc","dd","ee","dd","ee","aa","aa","bb"] ##生成列表 >>> a ['ee', 'cc', 'aa', 'ff', 'aa 阅读全文