zoukankan      html  css  js  c++  java
  • python切换任务操作

    尤其针对机器人调试的时候,我们希望它能够切换模式进行不同任务,但是python中并没有类似的if define或者switch等操作,

    但是可以做一个类似的switch,例如,本人也写了一个多任务执行模板

    
    task = 6 # choose which task to execute
    
    def task1(): 
        print("task 1 completed !")
    
    def task2():
        print("task 2 completed !")
       
    def task3():
        print("task 3 completed !")
        
    def task4():
        print("task 4 completed !")
    
    def task5():
        print("task 5 completed !")
    
    def task6()):
        print("task 6 completed !")
    
    def default():
        print("Invalid Operation!")
    
    switch={
        1:task1,
        2:task2,
        3:task3,
        4:task4,
        5:task5,
        6:task6,
    }
    
    switch.get(task,default)()
  • 相关阅读:
    JQ 放大镜
    Jquery.tmpl
    Jquery Live方法
    Bootstrap之底层媒体查询
    Bootstrap 字体与图标
    工具提示
    模态框
    BootStrap格栅系统
    Tab选项卡
    弹出框
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13281744.html
Copyright © 2011-2022 走看看