0317threading与字典函数使用

1)threading

def test():

    out=1

    return out

t=threading.Thread(target=test)

t1=threading.Thread(target=test()) #这个传进去为返回值

t.start ()# test在这执行

t1.start()#test函数在新建线程 已经执行,

2)字典函数

func_dic={}

# encoding: utf-8
import os
import sys

stack = []
class menu:
    def popit(self):
        if len(stack) == 0:
            print("stack is none ")
        else:
            print("remove",stack.pop())
        pass

    def pushit(self):

        stack.append(input("please append a new words:").strip())
        pass

    def viewStack(self):
        print(stack)

    CMDs={'o':popit,'u':pushit,'v':viewStack}

    def showMenu(self):
        pr="""
        P(U)sh
        p(O)p
        (V)iew
        (Q)uit

        enter choice"""

        while True:
            while True:
                try:
                    choise= input(pr).strip()[0].lower()
                    print(choise)
                except(EOFError,KeyboardInterrupt,IndexError):
                    choise = 'q'
                print('your input choise [%s]'%choise)

                if choise not in 'uvoq':
                    print("input error")
                else:
                    break
            if choise =='q':
                break
            self.CMDs[choise](self)
if __name__ == '__main__':
    m=menu()
    m.showMenu()




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值