摘要: import randomnumber = random.randint(1,100)guess = 0while True: num_in = input("Input your number please:") guess += 1 if not num_in.isdigit(): print( 阅读全文
posted @ 2017-12-12 15:29 anglesheepbobo 阅读(164) 评论(0) 推荐(0) 编辑
摘要: %——求模运算符直接算出余数,若可被整除则余数为0 i = "Please input number:" number = input(i) number = int(number) if number % 2 == 0 : print("The number" + number + "is eve 阅读全文
posted @ 2017-11-27 23:55 anglesheepbobo 阅读(525) 评论(0) 推荐(0) 编辑
摘要: 添加 xxx[key] = value 修改 xxx[key] = value 删除 del xxx[key] 输出 print(xxx[key]) 阅读全文
posted @ 2017-11-27 00:54 anglesheepbobo 阅读(185) 评论(0) 推荐(0) 编辑
摘要: [起:终]——切片 a = ['a','b','c','d','e'] print (a[1:4])——['b','c','d'] print(a[-3: ])——['c','d,'e'] print(a[ : 2])——['c','d','e'] 复制列表 新表 = 旧表[ : ]——切片为空 小 阅读全文
posted @ 2017-11-22 02:27 anglesheepbobo 阅读(92) 评论(0) 推荐(0) 编辑
摘要: range()函数——创建一个数值范围 range(起始值,终值) for i in range(1,10): print(i) list()函数——以“行”的方式输出 i = range(1,10) print(list(i)) == print(list(range(1,10)))——range 阅读全文
posted @ 2017-11-22 02:17 anglesheepbobo 阅读(697) 评论(0) 推荐(0) 编辑
摘要: abc = [a,b,c,d ] 新建列表abc abc[0] = 'a' 修改内容'a' abc.insert = (0,'a') 插入内容’a‘ print (abc[0]) 提取显示0位内容 del.abc[0] 删除0位内容 abc.pop() 提取最后一位内容,可再调用 abc.remov 阅读全文
posted @ 2017-11-17 11:34 anglesheepbobo 阅读(123) 评论(0) 推荐(0) 编辑
摘要: import xml.etree.ElementTree as ET 导入xml模块root = ET.parse('GHO.xml') 分析指定xml文件tree = root.getroot() 获取第一标签data = tree.find('Data') 查找第一标签中'Data'标签for 阅读全文
posted @ 2017-11-17 09:21 anglesheepbobo 阅读(4893) 评论(0) 推荐(1) 编辑
摘要: import json with open('jsonfile.json') as js:js = json.load(open('jsonfile.json')) ss = json.load(js)print(js) print(ss) 阅读全文
posted @ 2017-11-12 23:45 anglesheepbobo 阅读(1535) 评论(0) 推荐(0) 编辑
摘要: filename = 'mesg.csv' import csvwith open(filename)as fn: fn = csv.reader(open(filename,'r')) name = fn.read() for i in fn: print(name) print(i) 阅读全文
posted @ 2017-11-12 23:41 anglesheepbobo 阅读(245) 评论(0) 推荐(0) 编辑
摘要: from urllib import requesturl="http:........." #url地址Request = request.urlopen(url)Response=Request.read()with open('1.jpg','wb')as f: #保存在目录中 f.write 阅读全文
posted @ 2017-11-12 15:19 anglesheepbobo 阅读(95) 评论(0) 推荐(0) 编辑