用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中输入的命令行参数
相关文档:
这个代码是基于python3.0写的,有许多不完善的地方,请自已修改。
# coding: utf-8
from tkinter import *
root = Tk()
root.title("python3.0查询")
#root.minsize(800,600)
#填充无用空间
Label(root).grid(ipady=5)
#11面板
class Frame11:
def __init__(self, root): # ......
PyRSS2Gen :rss生成
下载地址:http://www.dalkescientific.com/Python/PyRSS2Gen-1.0.0.tar.gz
例子:
Java代码
import datetime
import PyRSS2Gen
rss = PyRSS2Gen.RSS2(
title = " ......
转自 http://hi.baidu.com/xunxun129/blog/item/3befad0f8ff992c07bcbe180.html
有时我们需要在 Python 中使用 zip 文件,而在1.6版中,Python 就已经提供了 zipfile 模块可以进行这样的操作。不过 Python 中的 zipfile 模块不能处理多卷的情况,不过这种情况并不多见,因此在通常情况下已经足够使用了。下面我只是对 ......