01 2018 档案

摘要:import xlwt#写入Excel: book = xlwt.Workbook() #新建一个excelsheet = book.add_sheet('sheet1') #添加一个sheet页sheet.write(0,0,'姓名')sheet.write(0,1,'性别')sheet.writ 阅读全文
posted @ 2018-01-31 15:31 hoby2017 阅读(159) 评论(0) 推荐(0)
摘要:import urllib.requestimport json,requests #发送get请求url = 'http://api.nnzhp.cn/api/user/stu_info?stu_name=小黑马'req = requests.get(url) #发送get请求print(req. 阅读全文
posted @ 2018-01-31 15:28 hoby2017 阅读(126) 评论(0) 推荐(0)
摘要:import pymysql import flask,json def op_mysql(host,user,password,db,sql,port=3300,charset='utf8'): conn = pymysql.connect(host=host,user=user, passwor 阅读全文
posted @ 2018-01-31 14:42 hoby2017 阅读(134) 评论(0) 推荐(0)
摘要:import redis r = redis.Redis(host='200.100.200.00',port=6300,password='123400',db=0)#连上redis r.set('nhy_session','201801211505') #set数据 r.get('马佩佩').d 阅读全文
posted @ 2018-01-31 14:07 hoby2017 阅读(138) 评论(0) 推荐(0)
摘要:import pymysql#1、连接上mysql ip 端口号 密码 账号 数据库#2、建立游标#3、执行sql#4、获取结果#5、关闭连接、关闭游标#1conn=pymysql.connect(host='211.149.218.16', user='jxz',passwd='123456',# 阅读全文
posted @ 2018-01-23 19:03 hoby2017 阅读(152) 评论(0) 推荐(0)
摘要:import hashlib# md5ybm_pwd='yuanbapqingsdfs234FF234HF@F' #m = hashlib.md5() #bytes_ybq = ybm_pwd.encode()#把字符串转成bytes类型m.update(bytes_ybq) #加密,不能字符串,只 阅读全文
posted @ 2018-01-16 18:24 hoby2017 阅读(152) 评论(0) 推荐(0)
摘要:1、处理json:import json#json串就是字符串。d = { 'car1':{'color':'red','price':100,'count':50}, 'car2':{'color':'red','price':100,'count':50}, 'car3':{'color':'r 阅读全文
posted @ 2018-01-15 18:06 hoby2017 阅读(1034) 评论(0) 推荐(0)
摘要:#函数即变量# len type print input strprint(all([1,0]))#判断可迭代的对象里面的值是否都为真print(any([0,1]))#判断可迭代的对象里面的值是否有一个为真print(bin(2))#十进制转二进制ejz = bin(100)print(ejz.r 阅读全文
posted @ 2018-01-15 17:50 hoby2017 阅读(130) 评论(0) 推荐(0)
摘要:#一个python文件就是一个模块#标准模块 python自带的,不需要安装的#第三方模块 需要安装,别人提供的 pip intall xxx 自动安装# 手动安装:下载安装包,解压,在命令行进入这个解压后的目录,执行python setup.py install#自己写的 自己写的python文件 阅读全文
posted @ 2018-01-11 17:38 hoby2017 阅读(170) 评论(0) 推荐(0)
摘要:# 函数 #函数 方法 功能 #说白了,函数就是把一堆代码组合到一起,变成一个整体。 #函数不调用不会被执行 #提高代码的复用性 #全局变量、局部变量 def hello(): print('hello')#函数不调用不会被执行hello()#调用函数def hello(file_name,cont 阅读全文
posted @ 2018-01-11 17:37 hoby2017 阅读(161) 评论(0) 推荐(0)
摘要:#集合 天生去重 s=set()#空的集合s2={'a','s','d'}s3={'a','s','d','y','u'}#集合是无序的,所以没有办法通过下标取值s2.add('q')s2.remove('a')#删除值s2.pop()#随机删除一个值# print(s2)print(s2.inte 阅读全文
posted @ 2018-01-11 17:07 hoby2017 阅读(119) 评论(0) 推荐(0)