zoukankan      html  css  js  c++  java
  • Python 简易Cmd控制

    Cmd控制

    昨天看到了别的组的部署方案,使用python来控制的,我们是用shell
    今天尝试了一下

    code

    import os
    import sys
    from cmd import Cmd
    
    class BingCmd(Cmd):
        """just try try"""
    
        prompt="BingCmd>"
    
        def print_log(self, argv):
            print("la la la ")
    
        def do_bing(self, argv):
            self.print_log(argv)
    
        def help_bing(self):
            print("just print la la la")
    
    if __name__ == "__main__":
        # import IPython
        # IPython.embed()
        BingCmd().cmdloop()
    

    运行结果

    $ python3 BingCmd.py
    BingCmd>help
    
    Documented commands (type help <topic>):
    ========================================
    bing  help
    
    BingCmd>bing
    la la la 
    
  • 相关阅读:
    简化单例模式
    static
    单例模式之懒汉模式
    Car race game
    poj-2403
    poj-2612
    poj-1833
    poj--2782
    poj--2608
    poj--3086
  • 原文地址:https://www.cnblogs.com/Draymonder/p/11981756.html
Copyright © 2011-2022 走看看