Python
lyle2000w
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python_API_os.path_isfile_待填充
os.path.isfile(path)Return True ifpath is an existing regular file. This follows symbolic links, so both islink() and isfile() can be true for the same path.原创 2012-05-23 16:05:25 · 350 阅读 · 0 评论 -
Python_格式化字符串
将python字符串格式化方法以例子的形式表述如下:* 定义宽度Python代码>>> '%*s' %(5,'some')' some'- 左对齐Python代码>>> '%-*s' %(5,'some')'some '最小宽度为6的2位精度的浮点小数,位数不够时前补空格Python代码>>> '%6.2f'转载 2012-04-26 14:39:52 · 436 阅读 · 0 评论 -
Python_API_String Services_string.strip
API文档:Return a copy of the string with leading and trailing characters removed. If chars is omitted or None, whitespace characters are removed. If given and not None, chars must be a string; the cha原创 2012-03-24 19:58:22 · 398 阅读 · 0 评论 -
Python_API_File and Directory Access_os.path.join
API文档:os.path.join(path1[, path2[, ...]]) Join one or more path components intelligently. If any component is an absolute path, all previous components (on Windows, including the previous drive原创 2012-03-24 20:47:21 · 721 阅读 · 0 评论 -
Python_API_File and Directory Access_os.path.expanduser
API文档:On Unix and Windows, return the argument with an initial component of ~ or ~user replaced by that user‘s home directory.On Unix, an initial ~ is replaced by the environment variable HOME i原创 2012-03-28 21:57:56 · 552 阅读 · 0 评论 -
Python_API_File and Directory Access_os.path.split
API文档:os.path.split(path)Split the pathname path into a pair, (head, tail) where tail is the last pathname component andhead is everything leading up to that. Thetail part will never contain a s原创 2012-03-28 22:20:23 · 619 阅读 · 0 评论 -
Python_API_String Services_string.find
API文档:string.find(s,sub[,start[,end]])Return the lowest index in s where the substringsub is found such thatsub is wholly contained ins[start:end]. Return-1 on failure. Defaults forstart and原创 2012-04-05 11:41:22 · 358 阅读 · 0 评论 -
Python_API_String Services_string.count
API文档:string.count(s, sub[, start[, end]]) Return the number of (non-overlapping) occurrences of substring sub in string s[start:end]. Defaults for start and end and interpretation of negative val原创 2012-04-05 12:35:25 · 396 阅读 · 0 评论 -
Python_API_Python Runtime Services_sys.modules
sys.modules是一个字典,他包含了从Python开始运行起,被导入的所有模块。键字就是模块名,键值就是模块队形。请注意除了你的程序导入的模块外还有其他模块。Python在启动时预先装入了一些模块,如果你在一个Python IDE环境下,sys.modules包含了你在IDE中运行的所有程序所导入的模块例子:import sysprint '\n'.join(原创 2012-03-28 21:38:41 · 505 阅读 · 0 评论 -
Python_API_Generic Operating System Services_os.environ
os.environ是系统上定义的环境变量的字典例子:import osprint os.environ输出{'TMP': 'C:\\Users\\LYLE20~1\\AppData\\Local\\Temp', 'COMPUTERNAME': 'LENOVO-PC', '1830B7BD-F7A3-4C4D-989B-C004DE465EDE': '17a4:原创 2012-03-28 22:07:24 · 542 阅读 · 0 评论 -
Python_API_String Services_string.replace
API文档:string.replace(str, old, new[, maxreplace]) Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxreplace is given, the first原创 2012-04-05 12:46:35 · 468 阅读 · 0 评论 -
Python_API_String Services_string.split
API文档:string.split(s[,sep[,maxsplit]])Return a list of the words of the string s. If the optional second argumentsep is absent orNone, the words are separated by arbitrary strings of whi原创 2012-04-05 15:31:02 · 677 阅读 · 0 评论 -
python_API_getopt
getopt在PYTHON中的使用 在运行程序时,可能需要根据不同的条件,输入不同的命令行选项来实现不同的功能。目前有短选项和长选项两种格式。短选项格式为"-"加上单个字母选项;长选项为"--"加上一个单词。长格式是在Linux下引入的。许多Linux程序都支持这两种格式。在Python中提供了getopt模块很好的实现了对这两种用法的支持,而且使用简单。一、取得命令转载 2012-05-17 12:37:21 · 350 阅读 · 0 评论 -
python压缩和解压zip
例如,在py脚本所在目录中,有如下文件:readability/readability.jsreadability/readability.txtreadability/readability-print.cssreadability/sprite-readability.pngreadability/readability.css将 readability 目录中转载 2012-05-23 15:48:28 · 401 阅读 · 0 评论 -
Python_API_os.path_exists_待填充
os.path.exists(path)Return True ifpath refers to an existing path. Returns False for broken symbolic links. On some platforms, this function may returnFalse if permission is not granted to exe原创 2012-05-23 16:00:25 · 952 阅读 · 0 评论 -
Python_API_ZipFile_close_待填充
ZipFile.close()Close the archive file. You must call close() before exiting your program or essential records will not be written.原创 2012-05-23 16:12:32 · 484 阅读 · 0 评论 -
Python_API_ZipFile_write_待填充
ZipFile.write(filename[,arcname[,compress_type]])Write the file named filename to the archive, giving it the archive namearcname (by default, this will be the same asfilename, but without a driv原创 2012-05-23 16:11:52 · 968 阅读 · 0 评论 -
Python_API_os.path_relpath_待填充
os.path.relpath(path[,start])Return a relative filepath to path either from the current directory or from an optionalstart point.start defaults to os.curdir.Availability: Windows, Unix.New原创 2012-05-23 16:10:28 · 1512 阅读 · 0 评论 -
Python_API_os_remove_待填充
os.remove(path)Remove (delete) the file path. If path is a directory,OSError is raised; seermdir() below to remove a directory. This is identical to theunlink() function documented below. On Win原创 2012-05-23 16:06:25 · 445 阅读 · 0 评论 -
Python_API_os_mkdir_待填充
os.mkdir(path[,mode])Create a directory named path with numeric modemode. The defaultmode is 0777 (octal). On some systems,mode is ignored. Where it is used, the current umask value is first mas原创 2012-05-23 16:01:47 · 397 阅读 · 0 评论 -
Python_API_zipfile.ZipFile_待填充
class zipfile.ZipFile The class for reading and writing ZIP files. See sectionZipFile Objects for constructor details.原创 2012-05-23 16:08:24 · 458 阅读 · 0 评论 -
Python_API_shutil_copy_待填充
shutil.copy(src,dst)Copy the file src to the file or directorydst. Ifdst is a directory, a file with the same basename as src is created (or overwritten) in the directory specified. Permission bit原创 2012-05-23 16:03:25 · 367 阅读 · 0 评论 -
Python_API_os.path_splitdrive_待填充
os.path.splitdrive(path)Split the pathname path into a pair (drive, tail) where drive is either a drive specification or the empty string. On systems which do not use drive specifications,drive wi原创 2012-05-23 15:58:42 · 884 阅读 · 0 评论 -
Python_API_os.path_walk_待填充
os.path.walk(path,visit, arg) Calls the function visit with arguments (arg, dirname, names) for each directory in the directory tree rooted at path (includingpath itself, if it is a director原创 2012-05-23 15:57:29 · 376 阅读 · 0 评论 -
Python_API_Built-in Functions_locals
API文档:locals() Update and return a dictionary representing the current local symbol table. Free variables are returned bylocals() when it is called in function blocks, but not in class原创 2012-04-07 17:17:05 · 376 阅读 · 0 评论 -
Python_API_Structured Markup Processing Tools_sgmllib.SGMLParser
API文档: This module defines a class SGMLParser which serves as the basis for parsing text files formatted in SGML (Standard Generalized Mark-up Language). In fact, it does not provide a full SGML原创 2012-04-07 15:59:13 · 462 阅读 · 0 评论 -
Python_API_Built-in Types_dict.update
update([other])Update the dictionary with the key/value pairs fromother, overwriting existing keys. ReturnNone.update() accepts either another dictionary object or an iterable of key/value pairs (原创 2012-03-24 10:31:44 · 781 阅读 · 0 评论 -
Python_API_Structured Markup Processing Tools_sgmllib.SGMLParser.reset
API文档:SGMLParser.reset() Reset the instance. Loses all unprocessed data. This is called implicitly at instantiation time.翻译文档: reset有SGMLParser的__init__调用,在reset进行初始化的工作。例子:#! /原创 2012-04-07 16:47:36 · 643 阅读 · 0 评论 -
python IDE比较与推荐
转载:水木社区- Python版发信人: RunningOn (挥着翅膀的男孩), 信区: Python标 题: python IDE比较与推荐发信站: 水木社区 (Mon Jul 16 19:34:58 2007), 转信我先给一个初步的表格吧,大家如果有什么意见,或有补充,欢迎提出。有些我没有用过,先不写了。以下是我使用过的python IDE:(更新与201转载 2012-03-07 10:12:52 · 388 阅读 · 0 评论 -
Python中数值和进制转换
Python数值和进制转换1.1 python中数值类型 int 整型 123 long 长整型 2147483648L float 浮点型 3.14不同的数值类型会自动扩充 int数值大于或等于2^31次方,会自动转换成long转载 2012-01-25 17:48:47 · 867 阅读 · 0 评论 -
python将字符串转成16进制的ASCii码的值
binascii.a2b_hex(hexstr)binascii.unhexlify(hexstr)Return the binary data represented by the hexadecimal string hexstr. This function is the inverse of b2a_hex(). hexstr must contain an even number转载 2012-01-25 17:50:05 · 14807 阅读 · 0 评论 -
python_模块与函数学习笔记
模块使用:方法1: 导入模块: import 模块名 调用模块: 模块明.函数名方法2: 导入模块: from 模块名 import 函数名 调用模块 函数名函数的定义和原创 2011-12-09 00:04:56 · 369 阅读 · 0 评论 -
python_变量+循环学习笔记
使用vim在ubuntu上学习python#!/usr/bin/env python#coding:utf8第1句保证ubuntu使用python来运行文件第2句是如过在代码中包含非ASCII的字符就需要使用#coding:utf8或是#coding=utf8注意;这里是包含顺行的,先执行的程序,再字符编码var = "4"print var*4原创 2011-12-06 17:31:49 · 483 阅读 · 0 评论 -
Python多线程学习
一、Python中的线程使用: Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: view plaincopy to clipboardprint?import time import thread def timer(no, inter转载 2011-11-19 15:52:13 · 336 阅读 · 0 评论 -
python_int类型转string
num=2;str(num);原创 2011-11-16 01:29:02 · 9584 阅读 · 0 评论 -
python_获取网页的内容和状态
import httplibconn = httplib.HTTPConnection("www.baidu.com");conn.request("GET", "/index.html");r1 = conn.getresponse();print r1.status, r1.reason;print("\n"+r1.read());conn.close();原创 2011-11-15 14:08:43 · 395 阅读 · 0 评论 -
python_Non-ASCII character
SyntaxError: Non-ASCII character '\xe7' in file 出现这种错误的原因是程序中的编码出问题了,只要在程序的最前面加上#-*- coding: UTF-8 -*-原创 2011-11-16 01:26:13 · 509 阅读 · 0 评论 -
Python_API_Structured Markup Processing Tools_sgmllib.SGMLParser.feed
API文档: SGMLParser.feed(data) Feed some text to the parser. It is processed insofar as it consists of complete elements; incomplete data is buffered until more data is fed or close() is called.原创 2012-04-07 16:39:22 · 610 阅读 · 0 评论 -
Python_API_String Services_re.sub
API文档:re.sub(pattern,repl,string[,count, flags])Return the string obtained by replacing the leftmost non-overlapping occurrences ofpattern instring by the replacementrepl. If the pattern isn’t原创 2012-04-05 16:56:44 · 361 阅读 · 0 评论 -
Python_API_File and Directory Access_glob.glob
API文档:globThe glob module finds all the pathnames matching a specified pattern according to the rules used by the Unix shell. No tilde expansion is done, but*,?, and character ranges expressed原创 2012-03-28 22:29:06 · 406 阅读 · 0 评论
分享