`
shopscor
  • 浏览: 19711 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论
文章列表
python ElementTree 基本读操作示例 演示用XML文件:test.xml view plaincopy to clipboardprint? <?xml version="1.0" encoding="utf-8"?> <root> <person age="18">     <name>hzj</name>     <sex>man</sex> </person> <person age=" ...
文章来自:http://hi.baidu.com/yobin/blog/item/572e554e51648f0fb3de05d9.html 一、python server(代码是蓝色部分,注释为黑色字体) #!/usr/bin/python import socket import re import os #第一步是创建socket对象。调用socket构造函数 socket = socket.socket( family, type ) #family参数代表地址家族,可为AF_INET或AF_UNIX。AF_INET家族包括Internet地址,AF_UNIX家族用于同一台机器上的 ...
文章来自:http://jordy.easymorse.com/?p=442。 python语言解析xml文件的常用的有两种方式:     * 通过MiniDom库解析xml文件     * 通过ElementTree库解析xml文件 MiniDom方式解析xml xml文件以data.xml为例,具体操作如下: data.xml: <?xml version="1.0" encoding="utf-8"?> <info>    <intro>保存用户的信息</intro>     <li ...
Python中的easy_install工具很爽,它的作用类似于Php中的pear,或者Ruby中的gem,或者Perl中的cpan。 如果想使用easy_install工具,可能需要先安装setuptools,不过更酷的方法是使用ez_setup.py脚本: wget -q http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py 安装完后,最好确保easy_install所在目录已经被加到PATH环境变量里。 比如说要安装Python的MySQL支持,可以执行如下命令,系统会自动在pypi网站列表里查找相关软件 ...
看一下三个函数: 1). commands.getstatusoutput(cmd) 用os.popen()执行命令cmd, 然后返回两个元素的元组(status, result). cmd执行的方式是{ cmd ; } 2>&1, 这样返回结果里面就会包含标准输出和标准错误. 2). commands.getoutput(cmd) 只返回执行的结果, 忽略返回值. 3). commands.getstatus(file) 返回ls -ld file执行的结果. 看一下这些函数使用的例子: >>> import commands >> ...
功能最强在的编辑器——vi vi是所有UNIX系统都会提供的屏幕编辑器,它提供了一个视窗设备,通过它可以编辑文件。当然,对UNIX系统略有所知的人, 或多或少都觉得vi超级难用,但vi是最基本的编辑器,所以希望读者能好好把它 ...
在我以前介绍 Python 2.4 特性的Blog中已经介绍过了decorator了,不过,那时是照猫画虎,现在再仔细描述一下它的使用。 关于decorator的详细介绍在 Python 2.4中的What’s new中已经有介绍,大家可以看一下。 如何调用decorator 基本上调 ...
#1、安装 好吧,我承认我只会最简单的安装 sudo apt-get install redis-server python 支持包: (其实就一个文件,搞过来就能用) sudo apt-get install python-redis #2、配置 配置一下吧,默认配置文件在: “/etc/redis/redis.conf” 绑定ip: “bind 127.0.0.1″ -> “bind 10.0.1.7″ 将磁盘同步改为 不同步或每秒同步,一直同步的话太慢了: “appendfsync always” -> “appendfsync no” 检查一下后台执行是否打开: “d ...
isinstance( object, classinfo)     Return true if the object argument is an instance of the classinfo argument, or of a (direct or indirect) subclass thereof. Also return true if classinfo is a type object and object is an object of that type. If object is not a class instance or an object of the gi ...
UUID objects (universally unique identifiers) according to RFC 4122. This module provides immutable UUID objects (class UUID) and the functions uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122. If all you want is a unique ID, you should proba ...
python提供了一个进行hash加密的模块:hashlib 下面主要记录下其中的md5加密方式     >>> import hashlib     >>> m = hashlib.md5()     >>> m.update("Nobody inspects")     >>> m.update(" the spammish repetition")     >>> m.digest()     '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd ...
Global site tag (gtag.js) - Google Analytics