2018年12月17日

django项目的上线问题

摘要: DEBUG = FalseALLOWED_HOSTS = ['*']1.静态文件加载不出来的问题:在settings.py中添加STATIC_ROOT = os.path.join(BASE_DIR,'static')在urls.py中添加from django.views import staticre_path(r'^static/(?P.*)$', static.serve, {'docum... 阅读全文

posted @ 2018-12-17 12:03 曹植 阅读(283) 评论(0) 推荐(0) 编辑

2018年12月12日

python 中PIL的用法

摘要: 1. Introduction PIL(Python Image Library)是python的第三方图像处理库,但是由于其强大的功能与众多的使用人数,几乎已经被认为是python官方图像处理库了。其官方主页为:PIL。 PIL历史悠久,原来是只支持python2.x的版本的,后来出现了移植到py 阅读全文

posted @ 2018-12-12 18:18 曹植 阅读(1152) 评论(0) 推荐(0) 编辑

2018年12月11日

mac地址的获取和修改

摘要: 若出现访问被拒绝的问题,可以在管理员windows powershell下运行代码。 阅读全文

posted @ 2018-12-11 15:00 曹植 阅读(700) 评论(0) 推荐(0) 编辑

2018年12月7日

json文件的保存,当遇到bytes格式无法序列化的问题解决方法

摘要: class MyEncoder(json.JSONEncoder): def default(self, obj): try: if isinstance(obj, bytes): return str(obj, encoding='utf-8') return json.JSONEncode... 阅读全文

posted @ 2018-12-07 17:57 曹植 阅读(1121) 评论(0) 推荐(0) 编辑

遍历文件夹下所有文件的路径

摘要: import os def traverse(f): fs = os.listdir(f) for f1 in fs: tmp_path = os.path.join(f, f1) if not os.path.isdir(tmp_path): print('文件: %s' % tmp_path) els... 阅读全文

posted @ 2018-12-07 17:52 曹植 阅读(524) 评论(0) 推荐(0) 编辑

windows注册表操作

摘要: #!/usr/local/bin/python3 __author__ = '曹植' import win32api import win32con import os import pywintypes import time class GoogleRegedit(object): """ 谷歌浏览器注册表方法实现 """ def __init__(s... 阅读全文

posted @ 2018-12-07 17:50 曹植 阅读(456) 评论(0) 推荐(0) 编辑

2018年12月5日

selenium设置proxy、headers(phantomjs、Chrome、Firefox)

摘要: 1.chrome浏览器 2.firefox浏览器 3.phantomjs浏览器 设置ip 方法1: 方法2: 还原为系统代理: 阅读全文

posted @ 2018-12-05 17:29 曹植 阅读(2070) 评论(0) 推荐(0) 编辑

selenium的用法2

摘要: 1.元素的定位 find_element_by_id find_element_by_name find_element_by_xpath find_element_by_link_text find_element_by_partial_link_text find_element_by_tag_ 阅读全文

posted @ 2018-12-05 15:32 曹植 阅读(94) 评论(0) 推荐(0) 编辑

2018年12月4日

selenium的用法1

摘要: 1、滚动条回到顶部: js="var q=document.getElementById('id').scrollTop=0" driver.execute_script(js) 或者 js="var q=document.documentElement.scrollTop=0" driver.ex 阅读全文

posted @ 2018-12-04 18:33 曹植 阅读(228) 评论(0) 推荐(0) 编辑

python sys中的stdin,stdout,stderr

摘要: 内部逻辑实现 重定向 Python提供了一个StringIO模块来完成这个设想,比如: >>> from StringIO import StringIO >>> import sys >>> buf=StringIO() >>> temp=sys.stdout #重定向前保存stdout >>>  阅读全文

posted @ 2018-12-04 18:02 曹植 阅读(1352) 评论(0) 推荐(0) 编辑

导航