1 Python 3.3.4 (v3.3.4:7ff62415e426, Feb 10 2014, 18:13:51) [MSC v.1600 64 bit (AMD64)] on win32 2 Type "copyright", "credits" or "license()" for more information. 3 >>> cast=["cleese","palin",&qu…
[1]a=[8,13,11,6,26,19,24]1)请输出列表a中的奇数项2)请输出列表a中的奇数 解:1) a=[8,13,11,6,26,19,24] print a[::2] Result:>>>[8, 11, 26, 24] 2) a = [8,13,11,6,26,19,24] b = [] for item in a: if item%2 !=0: b.append(item) else: continue print b Result:>>>[13, 1…
方法一: 元素两两比较,如果有数据不同,则r的值变为false #!/usr/bin/python a=[22,22,22,22] b = len(a) r=True for i in range(b): if i ==(b-1): break if a[i] == a[i+1]: continue else: r=False print(r) 方法二: 数据去重,如果去重后列表中的元素大于1,则说明数据重复 #!/usr/bin/python a=[22,22,22,222] b=len(se…
实现代码如下: # 读取配置文件,取其值组成列表class ReadTxt: def read_txt(self,path): li_info = [] with open(path) as f: li = f.readlines() for i in li: a = i.split("=")[1] b = a.strip("\n") li_info.append(b) return li_info…
配置文件: 源码: Dim Co As Object '设为全局变量 Function 读取cfg() As Boolean Dim strcfg As String strcfg = "D:\a.cfg" If Dir(strcfg, vbDirectory) = "" Then MsgBox "错误:配置文件不存在!" & Chr(10) & strcfg 'Chr(10)换行符 Exit Function End If S…