Draymonder

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 

分类:

技术点:

相关文章:

  • 2021-12-27
  • 2022-01-01
  • 2022-12-23
  • 2021-12-06
  • 2021-11-27
  • 2021-07-30
  • 2021-10-20
猜你喜欢
  • 2021-05-11
  • 2021-12-16
  • 2021-12-06
  • 2021-09-04
  • 2022-01-03
  • 2022-12-23
  • 2023-04-04
相关资源
相似解决方案