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

用python的cmd模块写一个简单的shell

 from cmd import *
class MyShell(Cmd):
    def preloop(self):
        print "print this line before entering the loop"
            
    def postloop(self):
        print "print this line after leaving the loop"
    
    def precmd(self, line):
        print "print this line before do a command"
        return Cmd.precmd(self, line)
    
    def postcmd(self, stop, line):
        print "print this line after do a command"
        return Cmd.postcmd(self, stop, line)   
            
    def do_test(self, line):
        ''' test command, just print the arguments except some special ones'''
        if line == "exit":
            exit()
        else:
            print line
    
MyShell().cmdloop()
#继承cmd模块的Cmd类实现
#shell中的命令xx在类中对应的函数名为do_xx
#line是shell中输入的命令行参数


相关文档:

Python笔记(二)——python调用C/C++模块

前一篇讲了简单的C/C++调用Python脚本模块(.py)。既然是用于诸多游戏程序的脚本语言,那肯定是缺不了互调(礼尚往来)。因此,本篇讲一个简单的python调用C/C++写的DLL模块,对Python进行功能扩展。这里写一个简单的例子,主要就为了了解下这么用Python来调用C/C++写的DLL库。好了,切入正题:
 首先,我是用VS2003 ......

python快捷键汇集


Ctrl+3            行注释
Ctr+\               去行注释
Ctrl+Shift+3   去行注释
Ctrl+4            块注释
Ctrl+5         & ......

python rss解析与生成

 PyRSS2Gen :rss生成 
下载地址:http://www.dalkescientific.com/Python/PyRSS2Gen-1.0.0.tar.gz 
例子:
Java代码 
import datetime  
import PyRSS2Gen  
  
rss = PyRSS2Gen.RSS2(  
   title = " ......

python pyc

 什么是pyc文件
pyc是一种二进制文件,是由py文件经过编译后,生成的文件,是一种byte code,py文件变成pyc文件后,加载的速度有所提高,而且pyc是一种跨平台的字节码,是由python的虚拟机来执行的,这个是类似于JAVA或者.NET的虚拟机的概念。pyc的内容,是跟python的版本相关的,不同版本编译后的pyc文件是不同的,2 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号