首页 软件开发 代码片段 python ( Page 67 )

python 1073

#Python
埃拉托塞尼筛法求素数

from math import sqrt N = 100 #生成一个列表,如果N是几百万,改成 xrange,效率也不高 a = range(0,N) #将不大于√N的素数的倍数…

2015-03-07 414

#Python
Python创建系统目录

import os def mkfilePower(path): '''create dirs if the path contain a file create a empty …

2015-03-06 130

#Python
免翻墙上google(python3.3版)已打包

#-*-coding:utf-8-*- #python3.3.5 import urllib.request,os,time,platform,shutil,re url='htt…

2015-03-06 935

#Python
在目录下查找包含某字符串的文件的python代码

一个search(s)的函数,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出完整路径: #!/usr/bin/env python import o…

2015-03-05 839

#Python
用pyinotify监控文件系统示例

    Pyinotify是一个Python模块,用来监测文件系统的变化。 Pyinotify依赖于Linux内核的功能—inotify(内核2.6.…

2015-03-05 664

#Python
批量抓取豆瓣电影TOP250数据

#!/usr/bin/env python import urllib.request from bs4 import BeautifulSoup mylist = [] prin…

2015-03-04 535

#Python
用XML_RPC实现P2P

# -*- coding: utf-8 -*- from xmlrpclib import ServerProxy, Fault from os.path import join,…

2015-03-04 792

#Python
保存芈月传的迅雷链接

import urllib import re import os import sys lst="myz.lst" bak_lst=lst+".bak" urls=[] def …

2015-03-03 540

#Python
python连接mongodb操作代码

__author__ = 'Administrator' #pip install pymongo from bson.objectid import ObjectId impor…

2015-03-03 323

#Python
基python实现多线程网页爬虫

#!/usr/bin/env python #coding=utf-8 import threading import urllib import re import time g…

2015-03-02 227

#Python
演示断言

#演示断言 #!/usr/local/bin/python2.5 def f(x): assert x < 1,'x must >= 1' return x**2 pr…

2015-03-01 815

#Python
专家级程序员写阶乘

#专家级程序员 import c_math fact = c_math.fact print fact(6) #英语系的专家级程序员 import c_maths fact = c…

2015-02-28 441
1 65 66 67 68 69 90