自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 资源 (1)
  • 收藏
  • 关注

原创 表示一段 bytes

b'\x10\x0\x0\x0\x10\x0\x0\x0' 这样写不正确必须b'\x10\x00\x00\x00\x10\x00\x00\x00'\x00 必须是两个0

2013-10-25 17:34:08 498

原创 csv

csv.reader(csvfile,dialect='excel', **fmtparams)返回一个reader 对象,将按照行遍历csvfile。csvfile 可以是任何支持iterator 并且__next()__返回一个字符串的对象。文件对象和列表都可以。如果csvfile是个文件对象,用open函数式,应指定关键之 newline=''  。eg:file=open(

2013-10-24 16:42:22 2460

原创 urllib.urlparse

urllib.parse.urlparse(urlstring,scheme='', allow_fragments=True)scheme:设置默认值allow_fragments:是否允许fragment>>> from urllib.parse import urlparse>>> o = urlparse('http://www.cwi.nl:80/%7Eguido/

2013-10-23 16:20:10 1290

原创 functools

import functoolsdef foo(a,b): return a+bprint(foo(3,4))7foo=functools.partial(foo,b=8)print(foo(3))11print(foo(3,b=4)) 7functools.reduce(function,iterable[, initializer])

2013-10-23 13:55:13 681

转载 python raise

原地址:http://openhome.cc/Gossip/Python/TryRaise.htmlexcept後若不接上任何例外型態,則表示捕捉所有例外,這包括了所有的系統例外,有時這並不是你想要的行為。例如,下面這個程式,無法透過KeyboardInterrupt來中斷迴圈:while True:    try:        print('Run it....')

2013-10-23 11:21:00 9953

原创 argparse 模块(一)

class argparse.ArgumentParser(prog=None, usage=None, description=None,epilog=None, parents=[], formatter_class=argparse.HelpFormatter, prefix_chars='-',fromfile_prefix_chars=None, argument_default=Non

2013-10-22 22:45:30 1209

原创 re

_URL_RE = re.compile(to_unicode(r"""\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&|")*(?:[^!"#$%&'()*+,.:;?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&|")*\)))+)"""))

2013-10-17 10:05:23 513

原创 re sub

_XHTML_ESCAPE_RE = re.compile('[&<>"\']')_XHTML_ESCAPE_DICT = {'&': '&', '': '>', '"': '"', '\'': '''}def xhtml_escape(value): """Escapes a string so it is valid within

2013-10-15 15:04:45 586

原创 list sort排序

files=['ik\\ikc000dir\\0.png', 'ik\\ikc000dir\\1.png', 'ik\\ikc000dir\\10.png', 'ik\\ikc000dir\\11.png', 'ik\\ikc000dir\\12.mmd', 'ik\\ikc000dir\\13.mmd', 'ik\\ikc000dir\\14.mmd', 'ik\\ikc000dir\\15.m

2013-10-15 10:35:44 662

原创 cp932 Shift_JIS

a

2013-10-15 10:09:43 1375

原创 decode('unicode_escape')

a='汉字'print(a)b=a.encode('unicode_escape')print(b)c=b.decode('utf-8')print(c)输出:汉字b'\\u6c49\\u5b57'\u6c49\u5b57

2013-10-14 11:41:19 6094

原创 python enumerate

def enumerate(collection): 'Generates an indexed series: (0,coll[0]), (1,coll[1]) ...' i = 0 it = iter(collection) while 1: yield (i, it.next()) i += 1

2013-10-11 21:53:00 512

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除