随笔分类 - Python
摘要: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
摘要:%——求模运算符直接算出余数,若可被整除则余数为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
摘要:添加 xxx[key] = value 修改 xxx[key] = value 删除 del xxx[key] 输出 print(xxx[key])
阅读全文
posted @ 2017-11-27 00:54
anglesheepbobo
摘要:[起:终]——切片 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
摘要: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
摘要: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
摘要: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
摘要: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
摘要: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
摘要: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
摘要:str(字符串)、int(数值)→ 变量 → 列表[ a,b ] → 字典{a:b} → 函数def a(); → 类class a(); 查看python文件路径: import sys import pprint pprint.pprint(sys.path) windows设置Python环境
阅读全文
posted @ 2017-11-12 15:01
anglesheepbobo

浙公网安备 33010602011771号