- 博客(24)
- 资源 (20)
- 收藏
- 关注
翻译 Python wrap实现简单的时间查看,修改器
from time import time, ctimeclass TimedWrapMe(object): def __init__(self, obj): self.__data = obj self.__ctime = self.__mtime = \ self.__atime = time() def ge
2014-12-26 10:36:15 749
原创 Python 使用list实现简单的map
# An map iteratorclass _MapIterator: def __init__(self, theList): self._mapItems = theList self._curItem = 0 def __iter__(self): return self def next(self):
2014-12-25 18:07:28 1963
翻译 Python 实现简单的迭代器
class AnyIter(object): def __init__(self, data, safe=False): self.safe = safe self.iter = iter(data) def __iter__(self): return self def next(self, howmany=1):
2014-12-25 11:20:35 560
翻译 Python 使用类实现简单的计时器
class Time60(object): 'Time60 - track hours and minutes' def __init__(self, hr, min): 'Time60 initializer - takes hours and minutes' self.hr = hr self.min = min d
2014-12-25 11:05:18 2229
翻译 Python 用类自定义数值的四舍五入
//code 1class RoundFloatManual(object): def __init__(self, val): assert isinstance(val, float), "Value must be a float!" self.value = round(val, 2)//outputIn [47]: rfm = RoundF
2014-12-25 10:01:38 1328
翻译 Python 使用list实现简单的set
# Implementation of iterclass _SetIterator: def __init__(self, theList): self._setItems = theList self._curItem = 0 def __iter__(self): return self def next(self):
2014-12-24 17:16:10 731
翻译 Python 正则表达式验证INI section blocks
(?ms)^\[[^]\r\n]+](?:(?!^\[[^]\r\n]+]).)*
2014-12-22 09:43:24 584
原创 Python 类指针操作
In [23]: friends_ids = []In [24]: followers_ids = []In [25]: for ids1, ids2 in [[friends_ids, followers_ids]]: ....: ids1 += '1' ....: ids2 += '2' ....:In [26]: id(ids1)Out[26]
2014-12-19 05:45:35 5314
翻译 Python 正则表达式从CSV文件提取特定列
Match string:1. Match a CSV record and capture the field in column 1 to backreference 1(?m)^([^",\r\n]+|"(?:[^"]|"")*")?(?:,(?:[^",\r\n]+|"(?:[^"]|"")*")?)*2. Match a CSV record and capture the fi
2014-12-18 11:11:17 3580
翻译 Python 正则表达式改变csv文件的分隔符
import resubject = '''aaa,b b,"""c"" cc"1,,"333, three,still more threes"'''result = ""reobj = re.compile(r'''(,|\r?\n|^)([^",\r\n]+|"(?:[^"]|"")*")?''')for matchobj in reobj.finditer(subject
2014-12-16 10:36:37 2865
翻译 Python 正则表达式查找XML注释中的特定词
1. Two-step approach import resubject = ''' This "TODO" is not within a comment, but the next one is. <!-- TODO : Come up with a cooler comment for this example. -->'''
2014-12-15 14:01:11 1610
翻译 Python 实现简单的GUI
from functools import partialimport Tkinterroot = Tkinter.Tk()MyButton = partial(Tkinter.Button, root, fg='white', bg='blue')b1 = MyButton(text='Button 1')b2 = MyButton(text='Button 2')qb = MyBu
2014-12-11 15:06:27 846
翻译 Python 正则表达式删除XML的注释
1. Xml commentMatch:Replace:NULL2 Html commentMatch:"']|"[^"]*"|'[^']*')*>.*?|"']|"[^"]*"|'[^']*')*>.*|"']|"[^"]*"|'[^']*')*>|Replace:NULL
2014-12-11 09:44:17 1659
翻译 Python 实现简单的加减猜结果游戏
#! /usr/bin/env pythonfrom operator import add, subfrom random import randint, choiceops = {'+': add, '-': sub}MAXTRIES = 2def doprob(): op = choice('+-') nums = [randint(1,10) for i i
2014-12-09 14:37:23 713
翻译 Python 正则表达式为XML中tags增加Attribute
Solution 1, simplisticMatch:]*?\scellspacing\b)([^>]*)>Replace:Solution 2, more reliableMatch:"']|"[^"]*"|'[^']*')*?\scellspacing\b)((?:[^>"']|"[^"]*"|'[^']*')*)>Replace:
2014-12-09 11:06:41 606
翻译 Python 正则表达式查找特定XML Tag中的Attribute
1. Tags that contain an id attribute (quick and dirty)]+\sid\b[^>]*>eg.2. Tags that contain an id attribute(more reliable)"']|"[^"]*"|'[^']*')+?\sid\s*=\s*("[^"]*"|'[^']*')(?:[^>"']|"[^"]*"|'[^
2014-12-08 12:01:16 3207
翻译 Python 正则表达式decode xml entities
法1:def xmlEntityDecode(capture1 = None, capture2 = None, capture3 = None): # Define name map dict nameDict = {'quot': 34, 'amp': 38, 'apos': 39,
2014-12-05 11:08:37 605
翻译 Python 正则表达式将纯文本转化为HTML格式
1. Detail stepStep 1: Replace HTML special characters with named character references& ---> & <> ---> >Step 2: Replace all line breaks with result = re.sub("\r\n?|\n", "", subject)Step
2014-12-01 11:23:13 1296 1
Practical Python and OpenCV, 3rd Edition.rar
2019-10-04
High Performance Python
2017-12-09
apache-maven
2017-09-06
CUDA for Engineers An Introduction to High Performance Parallel Computing
2017-06-06
load test for video publish, pull
2017-03-13
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人