随笔分类 - Python
摘要:product 笛卡尔积 (有放回抽样排列) permutations 排列 (不放回抽样排列) combinations 组合,没有重复 (不放回抽样组合) combinations_with_replacement 组合,有重复 (有放回抽样组合) >>> import itertools >>
阅读全文
摘要:import platform platform.architecture()
阅读全文
摘要:import re m = re.search('[0-9]', 'a1b2c3d4e5') print m.group(0) m = re.sub('[0-9]', 'X', 'a1b2c3d4e5') print m m = re.split('[0-9]', 'a1b2c3d4e5') print list(m) m = re.findall('[0-9]', 'a1b2c3d4e...
阅读全文
摘要:# encoding:utf-8 import urllib import os def Schedule(a,b,c): ''''' a:已经下载的数据块 b:数据块的大小 c:远程文件的大小 ''' per = 100.0 * a * b / c if per > 100 : per = 100 print '...
阅读全文
摘要:from multiprocessing import Process, Pool import time import subprocess def task(msg): print 'hello, %s' % msg time.sleep(1) def test_pool(): pool = Pool(processes=4) for x in ran...
阅读全文
摘要:import threading import subprocess import time def need_thread(func, *args, **kwargs): def fun(): print "sub:" + str(threading.current_thread().ident) time.sleep(1) sub...
阅读全文
摘要:import subprocess import os import sys import platform def fock_new(func): def inner(*args, **kwargs): if 'Linux'.__eq__(platform.system()): print "main process start" ...
阅读全文
摘要:import urllib url = "http://www.baidu.com" try: status = urllib.urlopen(url).code print status except: print {'result': 'false', 'msg': 'URL cannot access'}
阅读全文
摘要:import socket print socket.gethostname()
阅读全文
摘要:方法一:把cygwin的bin配置到环境变量里,这样做了以后在cmd.exe里也可以使用linux的命令 方法二:在运行的时候指定sh.exe位置
阅读全文
摘要:# coding:utf-8 import threading import time def test_xc(): f = open("test.txt","a") f.write("test_dxc"+'\n') time.sleep(1) mutex.acquire()#取得锁 f.close() mutex.release()#释...
阅读全文
摘要:text = "A2A"s = filter(lambda ch: ch in '0123456789', text)print int(s)
阅读全文
摘要:作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明。谢谢! 语言的内存管理是语言设计的一个重要方面。它是决定语言性能的重要因素。无论是C语言的手工管理,还是Java的垃圾回收,都成为语言最重要的特征。这里以Python语言为例子,说明一门动态
阅读全文
摘要:# coding:utf-8 class Properties: def __init__(self, file_name): self.file_name = file_name self.properties = {} try: fopen = open(self.file_name, 'r') ...
阅读全文

浙公网安备 33010602011771号