自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 收藏
  • 关注

原创 python写入文件乱码处理

import sysreload(sys)sys.setdefaultencoding('utf8')python写入文件 有时会报 UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 108: ordinal not in range(128 编码错误

2015-09-10 18:10:31 3541

转载 mac系统修改终端前缀

修改 hostname,可以参考如下命令:$sudo scutil --set HostName [你想要的新hostname]http://osxdaily.com/2006/12/11/how-to-customize-your-terminal-prompt/修改/etc/bashrc文件chmod 777 bashrc

2015-08-14 14:53:12 3441

原创 新浪短域名和百度短域名

主要针对短信的链接 或者 app push的链接处理如果链接过长 导致用户体验很差 所以使用新浪微博或百度的短链接功能两种短域名功能区别在于    新浪通过get请求 但需要有app key    百度不需要任何key 但需要post请求新浪短域名api文档地址:http://open.t.sina.com.cn/wiki/Short

2015-01-06 16:32:52 3796

原创 python处理datetime类型的时区转换

需求:数据库库中的数据是按照UTC时间进行存储 所以取出来显示给用户 需要处理一下时区>>>import pytz, datetime>>>tz0 = pytz.timezone('Europe/Brussels') # 获取比利时时区 >>>tz = pytz.timezone('Asia/Shanghai') # 获取上海时区 # 数据库取出的时间 转换成dateti

2014-12-31 18:25:38 3175

原创 python基础技巧

python内置函数查看所有内置函数dir(__builtin__)异常和警告:都是BaseException子类ArithmeticError,AssertionError,AttributeError,Exception,BaseException,BufferError,BytesWarning,DeprecationWarning,EOFError,Envi

2014-10-13 15:20:55 2239

原创 爬取双色球历史数据

爬取双色球历史数据爬去地址:http://baidu.lecai.com/lottery/draw/list/50?d=2014-01-01

2014-06-13 17:54:26 5492

原创 python开源ESB项目Zato技术分享

官网:https://zato.io简介:Zato是一个用Python编写的开源ESB和应用服务器。按照设计,它用于构建后端应用程序(即仅是API)和在SOA中整合系统什么是ESB和SOA?https://zato.io/docs/intro/esb-soa.html (牛逼的看这个)http://my.oschina.net/u/618083/blog/19652

2014-05-26 17:57:44 5899

原创 openerp通过Celery异步实时发送短信

github地址:https://github.com/xlsunchaoyx/openerp_celery

2014-05-26 16:47:12 2654

原创 fabirc的get或者put抛出的paramiko.ssh_exception.SSHException: Channel closed.

Traceback (most recent call last): File "/Library/Python/2.7/site-packages/fabric/main.py", line 743, in main *args, **kwargs File "/Library/Python/2.7/site-packages/fabric/tasks.py", line 368

2014-05-12 17:27:52 11384

原创 openerp增加交互环境shell.py脚本

依赖ipython# -*- coding: utf-8 -*-import sysimport osimport loggingimport ConfigParserfrom openerp.modules.registry import RegistryManagerfrom IPython import embed_logger = logging.getLogger(

2014-04-24 14:21:08 2571 2

原创 断点调试python代码

通过ipython调试from IPython import embedembed()通过pdbimport pdbpdb.set_trace()

2014-04-24 11:57:47 3350

转载 python去除html标签

sudo easy_install BeautifulSoupfrom BeautifulSoup import BeautifulSoupcontent = ''.join(BeautifulSoup("xxxxx").findAll(text=True))

2014-03-21 15:14:06 2530

原创 通过fabric自动更新服务器

通过fabric和sshpass无密码更新测试服务器代码示例# -*- coding: utf-8 -*-#!/usr/bin/pythonimport osfrom fabric.api import hosts, run, env, local, cd, get, lcdenv.hosts = ["[email protected]"]env.passwords =

2014-01-09 18:45:05 2820

原创 ubuntu安装sublime-text-2并修改为默认编辑器

1.无法直接安装 需要天假ppasudo add-apt-repository ppa:webupd8team/sublime-text-22.更新sudo apt-get update3. 安装sublime-text-2sudo apt-get install sublime-text-2-beta安装完成以后会生成/usr/share/applications/sub

2013-12-11 10:59:34 5140

原创 openerp开发ORM对象基本信息

openerp的ORM映射继承于from openerp.osv import osvclass Demo(osv.osv) # osv.Model 同 osv passORM 内置属性_name (必须 继承非必须) : 表名 .换成_ Default:None_columns (必须) :数据库字段 Example: _columns

2013-12-04 12:47:32 3327 3

原创 jquery拖拽排序控件DragSort

官网: dragsort.codeplex.com引入jquery包 然后导入diagsort包使用$("ul").dragsort()默认拖拽的标签的li可以通过修改dragSelector参数实现拖拽其他标签例如拖拽tr标签$("table").dragsort({ dragSelector: "tr"})停止拖拽

2013-11-06 17:51:15 12164

原创 django关于csrf防止跨站的ajax请求403处理

django配置文件通过中间件开启CSRF(Cross-site request forgery跨站请求伪造) 默认开启参考官方文档 django官方文档正常请求1.需要在views结尾传递context_instance=RequestContext(request)2.然后在模板的form标签内添加{% csrf_token %}异步请求第一种1.增加装饰器from

2013-10-11 11:35:57 3371

原创 KindEditor所见即所得异步ajax弹出窗加载

官网:http://www.kindsoft.net/正常加载代码如官网的文档 可以使用 KindEditor.ready(function(K) { window.editor = K.create('#editor_id'); });异步加载主要的问题是KindEditor.ready无法执行处理

2013-10-09 18:19:59 4111

原创 django传递公共参数到模板

因为显示需要,例如用户等信息是需要在每次请求传递回页面!django传递公共的参数到界面有两种方法1.中间件修改settings.py配置信息 MIDDLEWARE_CLASSES 增加自定义的中间件中间件的缺点是render_to_response无法触发process_template_response必须返回带有render()方法的HttpResponse()的实例

2013-09-25 18:28:48 3537 1

原创 web.py和postgres增删改查小例子

代码结构dmeo/ demo.sql demo.py demo.html edit.htmldemo.sql/* * CREATE DATABASE mydb TEMPLATE template0; 创建数据库 * psql mydb; 进入新创建数据库 * \i demo.sql 导入sql */CREATE TABLE

2013-05-02 16:46:53 1671

原创 postgresql常用命令

命令纪录来自 http://www.php100.com/manual/PostgreSQL8/本机环境ubuntu:adduser postgres        # 如果没有超级管理员 增加超级管理员sudo su - postgres      # 登录postgres账户ALTER USER postgres PASSWORD 'new pwd'; # 修改密码 修改密码后

2013-04-28 17:01:31 1171

原创 在ubuntu下安装PostgreSQL 9.0

最新版的直接可以用命令安装sudo apt-get install postgresql-xx如果想安装旧版本的 需要更新一下源 http://wiki.postgresql.org/wiki/Aptcd /etc/aptcp sources.list sources.list.oldsudo vi sources.list在sources.list追加de

2013-04-28 16:07:37 1070

原创 ubuntu下通过python处理word文件中的表格

简介:python处理word文件需要在windows下使用win32com,在linux下我没找到可以使用的包。解决办法:将doc文件转换成html,然后通过脚本解析html。安装:abiword是用来将doc转换成html的工具sudo apt-get install abiword转换命令,转换test.doc为test.htmlabiword --to=

2013-04-27 17:56:17 2676

原创 使用plupload实现无刷新上传图片

简介:plupload是一个web上传模块,能实现多文件上传,缩略图,进度条官网:http://www.plupload.com/index.php下载配置部分略过 以上下主题代码结构jQuery(function() { var uploader = new plupload.Uploader({ runtimes : 'html5,flash',

2013-02-19 15:47:56 4206 2

原创 通过js包ImgAreaSelect剪切头像

说明:因为有些浏览器不支持本地预览图片,所以通过js来对图片进行剪切只能通过先上传的方式在进行处理。如果想在未提交前处理图片只能通过flash方式。官方网站:http://odyniec.net/projects/imgareaselect/包:jquery-imgAreaselect 具体如何导入文件不再赘述 各种工程的配置方法不一简单的代码示例

2013-02-18 17:13:23 1562

原创 ubuntu安装phpmyadmin

在ubuntu下安装phpmyadmin管理数据库需要安装的包有apache2 php5 libapache2-mod-php5和mysql安装phpmyadmin命令sudo apt-get install phpmyadmin会自动依赖相关的包安装完成后 浏览器打开localhost 应该是apache2提示It works!然后打开localhost/phpmyadmin

2012-10-20 03:03:41 906 1

原创 linux命令

ubuntu目录中文转英文export LANG=en_USxdg-user-dirs-gtk-updateubuntu安装压缩sudo apt-get install unace unrar zip unzip p7zip-full p7zip-rar sharutils rar uudeview mpack lha arj cabextract file-ro

2012-10-10 08:22:30 803

原创 linux下搭建nginx,uwsgi和python的flask和django网站

nginx 官网 http://wiki.nginx.org/Mainuwsgi 官网 http://projects.unbit.it/uwsgi/wiki安装nginx 比较懒 直接用的命令安装ubuntu 下安装版本 1.1.19sudo apt-get install nginxcenos下 安装版本1.2.x忘记是多少了yum in

2012-09-07 00:22:53 2581

原创 python使用threading.Thread和Queue通过urllib2.urlopen抓取数据

有个抓取数据的需求 大概2000多个url 需要用到线程和队列线程和队列代码如下线程主体函数class ThreadWeather(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue

2012-09-03 12:39:40 2085

原创 python爬虫框架scrapy学习笔记

介绍:scrapy是一个python的爬虫框架 官方英文文档比较完整 支持web2.0官方文档:doc.scrapy.org本机环境:ubuntu 12.04安装命令:sudo easy_install python-twistedsudo easy_install w3libsudo easy_install lxmlsudo easy_install pyopenss

2012-08-02 11:00:56 7998

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除