易截截图软件、单文件、免安装、纯绿色、仅160KB

Python & XML


Chapter 1
Python and XML
Python and XML are two very different animals, each with a rich
history. Python is a full-scale programming language that has grown
from scripting world roots in a very organic way, through the vision
and guidance of Python's inventor, Guido van Rossum. Guido continues to
take into account the needs of Python developers as Python matures.
XML, on the other hand, though strongly impacted by the ideas of a
small cadre of visionaries, has grown from standards-committee roots.
It has seen both quiet adoption and wrenching battles over its future.
Why bother putting the two technologies together?
Before the Python/XML combination, there seemed no easy or effective
way to work with XML in a distributed environment. Developers were
forced to rely on a variety of tools used in awkward combination with
one other. We used shell scripting and Perl to process text and
interact with the operating system, and then used Java XML API's for
processing XML and network programming. The shell provided an excellent
means of file manipulation and interaction with the Unix system, and
Perl was a good choice for simple text manipulation, providing access
to the Unix APIs. Unfortunately, neither sported a sophisticated object
model. Java, on the other hand, featured an object-oriented
environment, a robust platform API for network programming, threads,
and graphical user interface (GUI) application development. But with
Java, we found an immediate lack of text manipulation power; scripting
languages typically provided strong text processing. Python presented a
perfect solution, as it combines the strengths of all of these various
options.
Like most scripting languages, Python features excellent text and
file manipulation capabilities. Yet, unlike most scripting languages,
Python sports a powerful object-oriented environment with a robust
platform API for network programming, threads, and graphical user
interface development. It can b


相关文档:

python中的exec 函数

      在项目里面一个解析文本的工具里面用到了这个命令来赋值,开始一直知道意思,呵呵 查了下,找到方法如下:
exec
语句用来执行储存在字符串或文件中的Python语句。例如,我们可以在运行时生成一个包含Python代码的字符串,然后使用
exec
语句执行这些语句。下面是一个简单的例子。
> ......

Python几种并发实现方案的性能比较

 
#!/Library/Frameworks/Python.framework/Versions/2.5/bin/python
# encoding: utf-8
import sys, time
import thread
 
SLEEP_TIME = 0.0001
 
def run_benchmark(n, m):
    # print(">> Python 2.5.1, stackless 3.1b3 here (N=%d, M=%d)!\n" % (n, m))
    lock ......

Python监视进程


由subprocess创建一个进程,然后进行监视
每一秒钟查看一次,如果正在运行,打印pid和running,如果已停止,,继续执行任务并打印Termined
shell和stdout均设置为False
也许这对做病毒的守护进程很好
#!/usr/bin/env python
import subprocess , sys , time
p=subprocess.Popen(['ping','127.0.0.1','-n','10'], she ......

Python 字符串方法


 
Python-String-Function
字符串中字符大小写的变换:
    * S.lower()   #小写
    * S.upper()   #大写
    * S.swapcase()   #大小写互换
    * S.capitalize()   #首字母大写
&n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号