易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : Python

Python: python写的一个简单网络词典

闲来无事, 玩玩python...
是采用有道翻译, 然后抓取网页的.
import re, urllib
url="http://dict.youdao.com/search?le=eng&q="
print ("input q to exit")
while 1:
word = raw_input(">>>")
if word=="q":
exit()
else:
word = word.replace(' ', '+')
url += word
url += "&tab=chn&keyfrom=dict.top"
s = urllib.urlopen(url).read()

comm1 = re.compile(';</td><td class="attributem1web">.*?</td>')
result=comm1.findall(s)
comm2 = re.compile(r'<td class="dttitle2"><font color="#013694"><b>.*?<\/b><\/font><\/td>')
related = comm2.findall(s)

#find the result
if result:
print 'meaning:'
for i in result:
temp = i.decode('utf8').encode('cp936')
temp = temp[33:]
temp = temp[:-5]
print temp
print '\n'
#fine the matters
if related:
print 'related:'
for i in related:
temp = i.decode('utf8').encode('cp936')
temp = temp[46:]
......

[Python module] select

16.1. select — Waiting for I/O completion¶
This module provides access to the select and poll functions available in most operating systems, epoll available on Linux 2.5+ and kqueue available on most BSD. Note that on Windows, it only works for sockets; on other operating systems, it also works for other file types (in particular, on Unix, it works on pipes). It cannot be used on regular files to determine whether a file has grown since it was last read.
The module defines the following:
这个模块提供大多数操作系统的select和poll功能。 epoll在Linux2.5+可用,kqueue则用于BSD。在winodws系统上,它仅用于socket,在其他系统下,它也可以用于其他类型(特别在 Unix 下,它还可以用于 管道)。它不能用来确定自从上次读取以后是否普通文件有所增长。
exception select. error ¶ The exception raised when an error occurs. The accompanying value is a pair containing the numeric error code from errno and the corresponding string, as would be printed by the C function perror .
在发生错误将引发 ......

[Python module] queue

8.8. queue — A synchronized queue class¶
queue -- 一个同步队列类
The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics. It depends on the availability of thread support in Python; see the threading module.
queue模块处理多生产者和多消费者的队列。在多线程间信息的安全交换非常有用。这个module的Queue类处理所需的locking语义,它依赖于threading模块。
Implements three types of queue whose only difference is the order that the entries are retrieved. In a FIFO queue, the first tasks added are the first retrieved. In a LIFO queue, the most recently added entry is the first retrieved (operating like a stack). With a priority queue, the entries are kept sorted (using the heapq module) and the lowest valued entry is retrieved first.
三种类型的队列,FIFO,LIFO,以及优先队列(使用heap ......

[Python module] threading

threading — Higher-level threading interface
This module constructs higher-level threading interfaces on top of the lower level _thread module. See also the queue module.
The dummy_threading module is provided for situations where threading cannot be used because _thread is missing.
 
这个模块是构建在底层_thread模块上的。
dummy_threading模块提供了可threading(由于_thread缺失)模块不能使用的情况。
 
Note
While they are not listed below, the camelCase names used for some methods and functions in this module in the Python 2.x series are still supported by this module.
This module defines the following functions and objects:
threading.active_count() Return the number of Thread objects currently alive. The returned count is equal to the length of the list returned by enumerate().
threading.Condition() A factory function that returns a new condition variable object. A condition variable allows one or more threads to wait until they are notified by another thread.th ......

用python, c#, java写的文件拷贝

     前一段时间试着用这三种语言简单的写了关于文件拷贝的程序,发现c#和python的api惊人的相似,对于文件的操作这两种语言非常的方便。都没有加异常的处理
C#源代码:
        public static void CopyFile(string source, string destination)
        {
            if (string.IsNullOrEmpty(source) | string.IsNullOrEmpty(destination))
            {
                throw new ArgumentNullException("传入的目录不存在");
            }
            if (IsDirectory(source))
            {
             ......

用python, c#, java写的文件拷贝

     前一段时间试着用这三种语言简单的写了关于文件拷贝的程序,发现c#和python的api惊人的相似,对于文件的操作这两种语言非常的方便。都没有加异常的处理
C#源代码:
        public static void CopyFile(string source, string destination)
        {
            if (string.IsNullOrEmpty(source) | string.IsNullOrEmpty(destination))
            {
                throw new ArgumentNullException("传入的目录不存在");
            }
            if (IsDirectory(source))
            {
             ......

用python, c#, java写的文件拷贝

     前一段时间试着用这三种语言简单的写了关于文件拷贝的程序,发现c#和python的api惊人的相似,对于文件的操作这两种语言非常的方便。都没有加异常的处理
C#源代码:
        public static void CopyFile(string source, string destination)
        {
            if (string.IsNullOrEmpty(source) | string.IsNullOrEmpty(destination))
            {
                throw new ArgumentNullException("传入的目录不存在");
            }
            if (IsDirectory(source))
            {
             ......

[Python module] multiprocessing


multiprocessing — Process-based “threading” interface
Introduction
multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Global Interpreter Lock by using subprocesses instead of threads. Due to this, the multiprocessing module allows the programmer to fully leverage multiple processors on a given machine. It runs on both Unix and Windows.
multiprocessing包利用threading模块相似的API来支持spawn进程。multiprocessing包有效的解决了GIL。
 
Warning
Some of this package’s functionality requires a functioning shared semaphore implementation on the host operating system. Without one, the multiprocessing.synchronize module will be disabled, and attempts to import it will result in an ImportError. See issue 3770 for additional information.
Note
Functionality within this package requires that the __main__ met ......
总记录数:695; 总页数:116; 每页6 条; 首页 上一页 [60] [61] [62] [63] 64 [65] [66] [67] [68] [69]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号