孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2012年9月20日

摘要: 1 #!/usr/bin/env python 2 #coding=utf-8 3 import os,sys 4 import shutil,re 5 6 def getparam(str): 7 file_re=re.compile(r'(\w*)(#{1,})(\w*)') 8 m=file_re.search(str) 9 return m.groups10 11 12 def changename(dir):13 filenum=014 i=int(sys.argv[3])15 list=os.listdir(dir) ... 阅读全文
posted @ 2012-09-20 21:00 孤独的猫 阅读(216) 评论(0) 推荐(0) 编辑

摘要: python类型转换、数值操作(收藏)最近学习python语言,碰到数据类型间的转换问题。看到一篇文章总结的挺详细,收藏之备用。类型转换代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 函数 描述2 int(x [,base ]) 将x转换为一个整数3 long(x [,base ]) 将x转换为一个长整数4 float(x ) 将x转换到一个浮点数5 complex(real [,imag ]) 创建一个复数6 str(x ) 将对象 阅读全文
posted @ 2012-09-20 20:05 孤独的猫 阅读(313) 评论(0) 推荐(0) 编辑

摘要: python 获取当前目录下文件2012-03-11 14:12:44| 分类: python | 标签:python file md5 |字号大中小 订阅 今天继续整理原来写的 python 代码,下面是获取文件信息的 python 处理代码。 获取指定目录下文件的文件名以及文件的数量,然后列出其中还存在的目录名称:#!/usr/bin/env python2#-*-encoding:utf-8-*-import os,sysdef listdir(dir,file):file.write(dir + '\n')fielnum = 0list = os.listdir(dir 阅读全文
posted @ 2012-09-20 18:06 孤独的猫 阅读(460) 评论(0) 推荐(0) 编辑

摘要: Python 描述符(descriptor) 杂记Python 引入的“描述符”(descriptor)语法特性真的很黄很暴力,我觉得这算是 Python 对象模型的核心成员之一。Python 语言设计的紧凑很大程度上得益于它。所以写一篇笔记文记录关于描述符我知道的一切。低层 - 纯纯的描述符纯纯的描述符很纯,基于类中定义的 __get__、__set__、__delete__ 三个特殊的方法。实现了这三个中方法的任意一个,这个类的实例就拥有了一些特殊特性。假设现在有这么一个类 MyDescriptor,它拥有描述符的实现。把 MyDescriptor 实例化(my_descriptor),然 阅读全文
posted @ 2012-09-20 13:36 孤独的猫 阅读(290) 评论(0) 推荐(0) 编辑

摘要: >>> help(locale) Help on module locale: NAME locale - Locale support. FILE c:\python27\lib\locale.py DESCRIPTION The module provides low-level access to the C lib's locale APIs and adds high level number formatting APIs as well as a locale aliasing engine to complement these. The aliasi 阅读全文
posted @ 2012-09-20 13:22 孤独的猫 阅读(189) 评论(0) 推荐(0) 编辑

摘要: python-查看帮助 摘自:http://blog.csdn.net/beiji_nanji/article/details/7460896help()一:不同的环境下1.交互模式下(命令行)查看模块的帮助信息:[python] view plaincopyprint?import pickle help(pickle) import picklehelp(pickle)可以看到详细信息,--More--上回车,滚动信息。q 退出帮助2.ide里,需要做一个输出。[python] view plaincopyprint?import pickle print(help(pickle)) im 阅读全文
posted @ 2012-09-20 13:18 孤独的猫 阅读(160) 评论(0) 推荐(0) 编辑