上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: Django的视图响应类型 一、 视图函数编写原则 视图函数接受HTTP请求并返回响应,可以放在任何地方,可以是任何功能;视图函数可以返回Web文本,页面、重定向、错误、图片等任何内容;视图函数通过HttpResponse、JsonResponse等类表达并返回响应;按约定,视图函数放在对应app中 阅读全文
posted @ 2018-01-16 10:44 xsan 阅读(360) 评论(0) 推荐(0) 编辑
摘要: Django2.0中URL的路由机制 路由是关联url及其处理函数关系的过程。Django的url路由配置在settings.py文件中ROOT_URLCONF变量指定全局路由文件名称。 Django的路由都写在urls.py文件中的urlpatterns列表中,由path()或re_path()作 阅读全文
posted @ 2018-01-16 09:01 xsan 阅读(14409) 评论(0) 推荐(0) 编辑
摘要: Python3安装scrapy框架步骤 1、 安装wheel a) Pip install wheel 2、 安装lxml Pip install lxml 3、 安装Twisted Pip install Twisted 4、 安装scrapy Pip install scrapy 阅读全文
posted @ 2018-01-07 16:16 xsan 阅读(939) 评论(0) 推荐(1) 编辑
摘要: Mysql中函数和存储过程的区别 存储过程: 1、 可以写sql语句 2、 inout,out构造返回值 3、 调用:call:存储过程名称 4、 可以返回结果集 函数: 1、 不可以写sql语句 2、 使用return 返回值 3、 调用时,使用函数名()即可 4、 不能获取结果集 阅读全文
posted @ 2018-01-01 21:21 xsan 阅读(428) 评论(0) 推荐(0) 编辑
摘要: Python中的三元运算 三元运算又称三目运算。 B=1 If B==1: a=123 else : a=456 上面程序等价于: B=1 a=123 if B==1 else 456 如果条件满足则a=123,否则a=456 阅读全文
posted @ 2017-12-31 16:31 xsan 阅读(233) 评论(0) 推荐(0) 编辑
摘要: Pymyaql操作数据库 Python3中专门用于操作Mysql数据库的模块。 一、 导入模块 import pymysql 二、 创建连接 conn=pymysql.connect(host=’127.0.0.1’,port=3306,user=’root’,passwd=’root’,db=’数 阅读全文
posted @ 2017-12-31 11:19 xsan 阅读(329) 评论(0) 推荐(0) 编辑
摘要: MySQL常用命令 一、用户管理 当IP地址为一段时是可使用通配符%,即'192.1638.1.%' 创建用户 create user '用户名'@'IP地址' identified by '密码'; 删除用户 drop user '用户名'@'IP地址'; 修改用户 remane user '用户 阅读全文
posted @ 2017-12-31 09:05 xsan 阅读(546) 评论(0) 推荐(1) 编辑
摘要: python实现微信接口(itchat) 安装 安装 sudo pip install itchat 登录 登录 itchat.auto_login() 这种方法将会通过微信扫描二维码登录,但是这种登录的方式确实短时间的登录,并不会保留登录的状态,也就是下次登录时还是需要扫描二维码,如果加上hotR 阅读全文
posted @ 2017-12-20 17:48 xsan 阅读(4931) 评论(0) 推荐(0) 编辑
摘要: python3通过qq邮箱发送邮件 0.了解qq邮箱的SMTP QQ邮箱 POP3 和 SMTP 服务器地址设置如下: 邮箱POP3服务器(端口995)SMTP服务器(端口465或587) qq.com pop.qq.com smtp.qq.com SMTP服务器需要身份验证。 1.开启qq邮箱的s 阅读全文
posted @ 2017-12-02 15:12 xsan 阅读(8490) 评论(0) 推荐(2) 编辑
摘要: centos 6和7通过yum安装的vim版本仍为7.4,若想尝鲜,可获取源码包编译安装。 准备工作 1.检查vim旧版本,若已存在,将其卸载。 $ vim$ yum remove vim* -y 2.安装终端字符处理库nucrses $ yum install ncurses-devel -y 编 阅读全文
posted @ 2017-11-19 11:42 xsan 阅读(3923) 评论(0) 推荐(0) 编辑
摘要: Python的re模块 1、 compile(pattern):创建模式对象 import re pat = re.compile('A') m = pat.search('CBA') #等价于re.search(‘A’,’CBA’) print(m) #<_sre.SRE_Match object 阅读全文
posted @ 2017-11-09 20:02 xsan 阅读(247) 评论(0) 推荐(0) 编辑
摘要: Python文件夹备份 import os,shutil def file_copy(path1,path2): f2 = [filename1 for filename1 in os.listdir(path2)] for filename in os.listdir(path1): if fil 阅读全文
posted @ 2017-11-08 21:44 xsan 阅读(1392) 评论(0) 推荐(0) 编辑
摘要: Python模糊查询本地文件夹去除文件后缀 import os,re def fuzzy_search(path): word= input('请输入要查询的内容:') for filename in os.listdir(path): #遍历指定文件夹 re_filename = re.finda 阅读全文
posted @ 2017-11-08 19:25 xsan 阅读(1802) 评论(0) 推荐(0) 编辑
摘要: Python正则表达式 原子是正则表达式中最基本的组成单位,每个正则表达式至少包含一个原子。常见原子类型有普通字符作为原子、非打印字符作为原子、通用字符作为原子、原子表。使用时需要调用re模块。 一、普通字符作为原子 Eg: import re string=”taoyunjioayu” pat=” 阅读全文
posted @ 2017-10-30 20:18 xsan 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Python的logging模块 一、简单的将日志打印到屏幕 import logging logging.debug('This is debug message') logging.info('This is info message') logging.warning('This is war 阅读全文
posted @ 2017-10-29 19:01 xsan 阅读(249) 评论(0) 推荐(0) 编辑
摘要: Python中hashlib模块 该模块主要用于数据加密。加密方式有md5、sha224、sha384、sha512、sha1、sha3_224、sha3_256、sha3_384、sha3_512等等加密方式。它通过一个函数,把任意长度的数据转换为一个长度固定的数据串(通常用16进制的字符串表示) 阅读全文
posted @ 2017-10-29 11:16 xsan 阅读(282) 评论(0) 推荐(0) 编辑
摘要: Python的os模块 一、os.getcwd() 获取当前工作目录。 import os print(os.getcwd()) # I:\Python程序 二、os.chdir(‘路径’) 改变当前脚本工作目录;相当于shell下cd。 三、os.curdir 四、os.pardir 五、os.m 阅读全文
posted @ 2017-10-28 11:12 xsan 阅读(293) 评论(0) 推荐(0) 编辑
摘要: Python生成随机验证码 一、 代码 二、 补充解释 Chr()将数字根据ASCII码,转换成对应内容。 阅读全文
posted @ 2017-10-27 12:17 xsan 阅读(511) 评论(0) 推荐(0) 编辑
摘要: Time模块和datetime模块 一、 调用 import time #调用time模块 二、使用方法 1、time.time 拿到时间戳。以Linux诞生年份1970年开始计算到程序执行时刻的秒数。 2、time.sleep() 使程序暂停暂停若干秒。 time.sleep(3) #使程序暂停暂 阅读全文
posted @ 2017-10-27 09:53 xsan 阅读(179) 评论(0) 推荐(0) 编辑
摘要: For循环的实质 1、调用可迭代对象的iter方法返回一个迭代器对象 2、不断调用迭代器对象的next方法 3、处理StopIteration 阅读全文
posted @ 2017-10-26 10:16 xsan 阅读(200) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 下一页