博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python cmd 模块测试
阅读量:4215 次
发布时间:2019-05-26

本文共 650 字,大约阅读时间需要 2 分钟。

#!/usr/bin/pythonfrom cmd import Cmdimport osimport sysclass cli(Cmd):        prompt ='tao>'        intro = "welcom test"        def __init(self):                Cmd.__init__(self)        def do_hello(self,args):                print "hello",args        def do_exit(self,args):                print "exit"                return True        def default(self,args):                print "pardon ?"if __name__ == '__main__':        try:                test=cli()                test.cmdloop()        except:                exit()测试结果如下:tiantao@BoardServer2:~$ python cmd_test.pywelcom testtao>hellohellotao>hello taohello taotao>qwerpardon ?tao>exitexit

 

转载地址:http://bvnmi.baihongyu.com/

你可能感兴趣的文章
NIO
查看>>
Java NIO理解与使用
查看>>
Mark :Spark Streaming 反压(Back Pressure)机制介绍
查看>>
【Big Data 每日一题20180814】hadoop中有几个文件,spark就会有几个Partition么?
查看>>
【Big Data 每日一题20180815】 HBase 与 zookeeper 之间的关系?
查看>>
【Big Data 每日一题】目录
查看>>
【Big Data 每日一题20180816】 数组为什么比list 效率高?
查看>>
【Big Data 每日一题20180821】Spark中ml和mllib的区别
查看>>
【Big Data 每日一题20180822】Java动态编译优化——URLClassLoader 内存泄漏问题解决
查看>>
【Big Data 每日一题20180823】Linux 中 ulimit 作用
查看>>
Spark Structured Stream的流关联(Stream-Stream Joins)
查看>>
【Big Data 每日一题20180827】linux 管道命令 与 管道通信
查看>>
【Big Data 每日一题20181111】为什么有栈内存和堆内存之分
查看>>
【Big Data 每日一题20180828】Maven 中 jar 包的 Snapshot 和 Release 版本区别
查看>>
【Big Data 每日一题20180829】Spark on Yarn 的两种运行模式?
查看>>
【Big Data 每日一题20180830】Metrics 入门教程 关于 Metrics ?
查看>>
【Big Data 每日一题20180831】Spark 的 task 数据 locality?
查看>>
大数据框架、概念等 简短总结 (持续总结中)
查看>>
【Big Data 每日一题20180901】 Kafka相对传统技术有什么优势
查看>>
【Big Data 每日一题20180902】 Kafka 最大的特点?
查看>>