- 博客(15)
- 收藏
- 关注
原创 sphinx-for-python
1、安装:http://gisellezeno.com/tutorials/sphinx-for-python-documentation.htmlpip install sphinx2、使用命令:sphinx-quickstart试参考示例:https://pythonhosted.org/an_example_pypi_project/sphinx.html
2016-01-24 20:05:34
442
原创 使用MySQL-python操作MySQL数据库
1、安装MySQL2、安装MySQL-pythonpip install MySQL-python安装的时候会有些问题出现,但是使用百度或者谷歌很好解决,没做记录3、安装logging(此处的logging只是附加的)pip install logging4、代码:#!/usr/bin/python#coding:utf-8import MySQLdbimport
2016-01-09 16:56:10
289
原创 使用sqlalchemy连接sql数据库并做简单操作
1、安装MySQL这个文章很多,不去重复(mysql-server,mysql-client)2、安装SQLAlchemy pip install SQLAlchemy3、安装logging模块pip install logging4、直接上代码,已经写好注释#!/usr/bin/python#coding:utf-8from sqlalchemy import
2016-01-09 16:44:47
1080
原创 python socket编程(2)-SocketServer 模块
之前写的网络编程的只是为了理解socket编程的过程,如果真的要写这样的程序,还不如用c来写,代码效率高的不是一点俩点。记得大二写过c的socket编程,都按qq的方式写的。添加好友,用户对话,自动回复。正题来了SocketServer模块是标准库中的一个高级别模块。用来简化实现网络客户端与服务器所必须的大量样式编码。SocketServer 模块的类
2015-12-27 22:11:40
472
原创 python socket编程(1)
socket()编程由于socket模块中用到的属性很多,简化代码先使用from socket import *#正常不要使用*,依次导入需要的属性和方法创建一个TCP/IP的套接字tcpsock = socket(AF_INET,SOCK_STREAM)创建一个UDP/IP的套接字udpsock = socket(AF_INET
2015-12-27 22:05:26
298
翻译 writing idiomatic python 读书笔记(8)
建议:一、不要重复造轮子1.了解PyPI2.学习python标准库内容二、模块1.学习itertools 模块itertools模块提供了一系列迭代器能够帮助用户轻松地使用排列、组合、笛卡尔积或其他组合结构。2.使用 os.path模块 处理目录的时候三、测试1.使用自动化测试工
2015-12-26 14:16:04
286
原创 writing idiomatic python 读书笔记(7)
格式化1.全局变量大写2.根据PEP8格式化代码在编译器上安装好PEP8style-checking插件Identifier Type Format ExampleClass Camel case class StringMani
2015-12-26 14:14:49
301
原创 writing idiomatic python 读书笔记(6)
Context Managers上下文管理器,作用:with open(filename, mode) as writer: writer.write('Hello ') writer.write('World')简化这样的操作:writer= open(filename, mode)try:writer.wri
2015-12-26 14:12:54
352
原创 writing idiomatic python 读书笔记(5)
classes(1)使用isinstance函数 来判断一个对象的类型isinstance(object, class-or-object-or-tuple)第二个参数不能为object。可以是type的tuple这个函数在很多地方应该用到,很多新手和我一样没用在正确地方吧。def get_size(some_object): """Ret
2015-12-26 14:10:12
329
原创 nginx+uwsgi+flask小例子
准备买个阿里云搭个网站,由于还没开始写网站,所以就先有本地实验一下,网上找了很多关于nginx+uwsgi的资料,可能是我自己手残的原因,总是搭建有问题。结合了几篇文章,最后用了一天时间才做完。。。不希望忘了写下来:1、安装virtualenv这个看这文章的小伙伴应该都会。。。2、在/home/www/my_flask/下新建 virtualenv venv
2015-12-26 14:05:49
600
原创 writing idiomatic python 读书笔记(4)
个人学习python代码的记录,writing idiomatic python 学习如何写出合格的python代码
2015-12-23 17:34:24
275
原创 writing idiomatic python 读书笔记(3)
变量(1)使用多作业去压缩变量设置相同值简洁也不影响可读性x = y = z = 'foo'(2)避免使用不必要的临时变量foo = 'Foo'bar = 'Bar'(foo, bar) = (bar, foo)字符串(1)字符串函数链来处理字符串但是不要串太多,最好不要超过3个book_info = ' The Three Musketeers:...
2015-12-23 16:02:04
346
原创 writing idiomatic python 读书笔记(2)
个人学习python代码的记录,writing idiomatic python 学习如何写出合格的python代码
2015-12-23 13:41:40
317
原创 writing idiomatic python 读书笔记(1)
个人学习python代码的记录,writing idiomatic python 学习如何写出合格的python代码
2015-12-23 13:29:15
383
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人