摘要:
>>> 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 阅读全文
摘要:
1、 >>> a = ["aa","cc","aa","bb","bb","aa","dd","ee"] >>> a ['aa', 'cc', 'aa', 'bb', 'bb', 'aa', 'dd', 'ee'] >>> "aa" in 阅读全文
摘要:
>>> a = ["dd","cc","aa","bb"] >>> a ['dd', 'cc', 'aa', 'bb'] >>> b = sorted(a) ## 排序并赋值给b >>> b ['aa', 'bb', 'cc', 'dd'] >>> a ['dd', 'cc 阅读全文
摘要:
>>> a = ["aa","bb","cc","dd","ee","ff","gg","hh"] >>> a ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh'] >>> a.pop() ## pop删除 阅读全文
摘要:
>>> a = ["aa","bb","cc"] ## 创建列表 >>> a ['aa', 'bb', 'cc'] >>> a.append("dd") ## append添加 >>> a ['aa', 'bb', 'cc', 'dd'] >>> a.extend(["ee"]) >> 阅读全文