ChinaUnix.net
相关文章推荐:

python实现下载

python写了一个HTTP的多线程 下载 程序,代码还很简单,连接错误处理、重试等还都没有写,晚上有时间再完善完善。 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/5017/showart_194744.html

by recordus - Python文档中心 - 2006-11-03 12:00:39 阅读(1344) 回复(0)

相关讨论

这是一个有着真实需求的实现,我的用途是拿它来通过 HTTP 方式向服务器提交游戏数据。把它放上来也是想大家帮忙挑刺,找找 bug,让它工作得更好。 # -*- coding:utf-8 -*- import urllib, httplib import thread import time from Queue import Queue, Empty, Full HEADERS = {"Content-type": "application/x-www-form-urlencoded",               ...

by dooros - Python文档中心 - 2009-04-29 11:17:37 阅读(2084) 回复(0)

转自 http://www.lixiaodou.cn/?cat=8 # -*- coding: utf-8 -*- def charu(list): length = len(list) for i in range(1,length): temp = list j = i - 1 while list[j] > temp: list[j+1] = list[j] list[j] = temp j = j - 1 if j 0: break return list def xuanze(list): length = len(list) for i in range...

by BENNYSNAKE - Python文档中心 - 2009-05-25 18:05:36 阅读(1259) 回复(0)

爬虫工作的基本原理就是,给定一个初始的url,下载这个url的网页,然后找出网页上所有满足下载要求的链接,然后把这些链接对应的url下载下来,然 后再找下载下来的这些网页的url,我们可以用广度优先搜索实现这个算法. #!/usr/bin/python import urllib2 import re def downURL(url,filename): print url print filename try: fp = urllib2.urlopen(url) except: print 'download exception' ...

by alexnetwork - Python文档中心 - 2009-03-18 21:49:45 阅读(1406) 回复(0)

python实现> 最近在学习python,又不知道写个什么来练手,就想到用python实现>里面的例程, <一> 第二章,例2-3的清除函数: #! /usr/bin/env python # -*- coding:utf-8 -*- #TO: #BY: #File: cleanup.py #Date: 2008-00-12/26/08 # import os import sys LOG_DIR="/var/log" ROOT_UID=0 LINES=50 E_XCD=65 E_NOTROOT=67 if os.getuid() != ROOT_UID: print "Must be root to run this script." sys.exit(E...

by yk325 - Python文档中心 - 2008-12-26 15:42:04 阅读(1333) 回复(0)

http://hit168.qyun.net 这里还有其它计算机书籍下载 python_XML Core_python python_Essential_Reference python_Library_Reference python.in.a.Nutshell Advanced_python_programming GUI_Programming_with_python learning.python Mobile_python_-_Rapid_Prototyping_of_Applications_on_the_Mobile_Platform_ python_Programming_on_Win32 python_-_HowTo_-_Regular_Expressions python_for_Massively_Multiplayer_Virtual_...

by hit168 - Python文档中心 - 2009-03-17 15:23:06 阅读(1559) 回复(0)

http://hit168.qyun.net 这里还有其它计算机书籍下载 python_XML Core_python python_Essential_Reference python_Library_Reference python.in.a.Nutshell Advanced_python_programming GUI_Programming_with_python learning.python Mobile_python_-_Rapid_Prototyping_of_Applications_on_the_Mobile_Platform_ python_Programming_on_Win32 python_-_HowTo_-_Regular_Expressions python_for_Massively_Multiplayer_Virtual_...

by hit168 - Python文档中心 - 2009-03-12 09:51:11 阅读(1194) 回复(0)

处理了etag和lastmodified,和gzip。 避免了重复或许,节省带宽。 #!/usr/bin/env python import openanything USER_HTTP_AGENT = 'python http downloader' class http_downloader(): def __init__(self,url): self.result = {} self.result['url'] = url self.result['etag'] = None self.result['lastmodified'] = None def fetch(self): f = openanything.openAn...

by u0u0 - Python文档中心 - 2008-09-08 16:04:36 阅读(1995) 回复(0)

Example 4: Koch curveA variant of the Koch curve which uses only right-angles. variables : F constants : + − start : F rules : (F → F+F−F−F+F) Here, F means "draw forward", + means "turn left 90°", and - means "turn right 90°"(see turtle graphics). n = 0: F n = 1: F+F-F-F+F n = 2: F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F n = 3: F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+...

by blackjimmy - Python - 2009-05-10 12:32:08 阅读(1537) 回复(0)

#!/usr/bin/python import smtplib, email import os, sys import hashlib def send_mail(send_from, send_to, subject, text, attachment_bytes, auth=(), send_server='localhost'): msg = email.MIMEMultipart.MIMEMultipart() msg['From'] = send_from msg['To'] = email.Utils.COMMASPACE.join(send_to) msg['Date'] = email.Utils.formatdate(localtime=True) msg['Subject'] = subject msg.atta...

by alexnetwork - Python文档中心 - 2009-03-18 20:54:33 阅读(1387) 回复(0)

#!/usr/bin/python import sendpkt import dpkt import os import re import socket import struct import string import sys import signal iface = "eth0" mac = "00:09:5B:98:0D:85" inet = "10.29.1.61" debug = False # this should be somewhere is dpkt ? ETH_ADDR_BROADCAST = '\xff\xff\xff\xff\xff\xff' ETH_ADDR_UNSPEC = '\x00\x00\x00\x00\x00\x00' def eth_ntoa(buffer): # Convert binary data into a stri...

by alexnetwork - Python文档中心 - 2009-03-18 13:20:56 阅读(2271) 回复(0)