摘要: 经常会运行类似这样的命令nohup python main-script.py arg1 arg2 > log2.txt 2>&1 &nohup 命令运行由 Command参数和任何相关的 Arg参数指定的命令,忽略所有挂断(SIGHUP)信号。也就是说当你按下Ctrl+D从Linux注销用户以... 阅读全文
posted @ 2014-12-09 20:38 jaw-crusher 阅读(675) 评论(0) 推荐(0) 编辑
摘要: URL就是我们天天使用的网址,英文全称叫做uniform resource locator,你可以把它理解成互联网上每个页面独一无二的名字.其实也不全是页面了,比如一些FTP下载资源,或者网页上的mailto链接,都是使用URL表示的.其实URL就相当于互联网字典上的索引,这些URL本来是一个个... 阅读全文
posted @ 2014-11-16 22:50 jaw-crusher 阅读(2049) 评论(0) 推荐(0) 编辑
摘要: 使用Python可以很快得到一些系统的信息,比如平台,字节序,和Python最大递归限制,比如:import sys# get byte orderprint sys.byteorder# get platform print sys.platform# nothing to say ^_^pri... 阅读全文
posted @ 2014-11-01 18:45 jaw-crusher 阅读(598) 评论(0) 推荐(0) 编辑
摘要: 貌似没有现成的函数,可以自己简单实现一下:import requestsimport jsondef get_my_ISP_address(): ip = 'unkown' try: request_content = requests.get('http://httpbin.org/i... 阅读全文
posted @ 2014-10-12 17:14 jaw-crusher 阅读(379) 评论(0) 推荐(0) 编辑
摘要: 实例如下:import botofrom boto import connectionimport os, mathfrom filechunkio import FileChunkIO# fill in the id and keyconn = boto.connect_s3()print con... 阅读全文
posted @ 2014-10-10 16:54 jaw-crusher 阅读(1210) 评论(0) 推荐(0) 编辑
摘要: import mathfrom itertools import imapv1 = [30, 20, 20, 10, 0]v2 = [40, 0, 30, 20, 10]dot_product = sum(imap(lambda a, b: a * b, v1, v2))module_one = m... 阅读全文
posted @ 2014-09-12 16:53 jaw-crusher 阅读(390) 评论(0) 推荐(0) 编辑
摘要: 使用[] + for语句是解析列表而使用() + for语句是产生生成器实例代码如下:alist = [1, 2, 3, 4, 5]another_list = [i for i in alist]print another_lista_generator = (i for i in alist)p... 阅读全文
posted @ 2014-06-12 15:32 jaw-crusher 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 对于大量数据写入excel文件,如果使用了表格样式而且在循环中定义了样式,就是产生了easyxf对象,那么最多只能新建4094个对象,然后会抛出More than 4094 XFs (styles)的异常,对于这种情况,简单的解决方案是把样式定义在循环之外,比如:# -*- coding: ut... 阅读全文
posted @ 2014-05-21 14:44 jaw-crusher 阅读(6683) 评论(1) 推荐(1) 编辑
摘要: 在做网络爬虫的时候会遇到json数据格式的数据包,如果返回的是一个json格式的文件,可以使用Python Yaml包处理数据,不需要再使用正则表达式匹配了,使用实例如https://maps-api-ssl.google.com/maps/suggest?q=hello 这个地址,我们需要que... 阅读全文
posted @ 2014-05-19 16:58 jaw-crusher 阅读(730) 评论(0) 推荐(0) 编辑
摘要: Python读写中文变量总会有问题,尤其是读写Windows下的txt文件,如果把文件保存为UTF8格式就没问题了,如新建一个txt文件,另存为UTF8格式:然后运行测试的Python代码:# -*- coding: utf-8 -*-fd = open("./data.txt", "w")stri... 阅读全文
posted @ 2014-04-21 17:43 jaw-crusher 阅读(4981) 评论(0) 推荐(0) 编辑