内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

python模擬隊列和堆棧(列表練習)-創(chuàng)新互聯(lián)

##################################queue#########################################
#!/usr/bin/env python

'use list as a queue'

#define a void list as a void queue
queue = []

#define in queue function
def enQ():
    queue.append(raw_input('Enter New String: ').strip())

#define out queue function
def deQ():
    #judge queue whether viod
    if len(queue) == 0:
        print('Can not pop from an empty queue!')
    else:
        print('Removed' ,queue.pop(0))

#define show queue function
def viewQ():
    print(queue)

#define a dictionary to chose opration function
cmds = {'e':enQ,'d':deQ,'v':viewQ}

#define a funtion to show menu
def showMenu():
    pr = '''
    (E)nqueue
    (D)equeue
    (V)iew
    (Q)uit
    
    Enter choice:'''

    #double while circle make program always run
    while True:
        while True:
            try:
                #use to print menu information and get valid choice number(no space, just one bit , lower)
                choice = raw_input(pr).strip()[0].lower()
            except(EOFError,KeyboardInterrupt,IndexError):
                #if get a invalid value,return 'q'
                choice = 'q'
                
            print('You picked: %s '% choice)
            if choice not in 'devq':
                print('Invalid option, try again!')
            else:
                break

        if choice == 'q':
            break
        #call functions by dictionary
        cmds[choice]()

#main function
if __name__ == '__main__':
    showMenu()
    
    
 ##################################stack######################################
 #!/usr/bin/env python

'this program use list as a stack'

stack = []

def pushit():
    'input stack '
    stack.append(raw_input('Enter New Strings: ').strip())

def popit():
    'output stack'
    if len(stack) == 0:
        print('Can not pop from an empty stack!')
    else:
        print('removed [',stack.pop(),']')

def viewStack():
    print(stack)

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

def showMenu():
    pr = '''
    p(U)sh
    p(O)p
    (V)iew
    (Q)uit
    Enter Choice:
 
'''
    while True:
        while True:
            try:
                choice = raw_input(pr).strip()[0].lower()
                print(choice)
            except(EOFError.KeyboardInterrupt,IndexError):
                choice = 'q'
            print('you picked: %s ' % choice) 
            if choice not in 'uovq':
                print('Invalid option, try again')
            else:
                break

        if choice == 'q':
            break
        CMDs[choice]()

if __name__ == '__main__':
    showMenu()

目前成都創(chuàng)新互聯(lián)公司已為成百上千家的企業(yè)提供了網(wǎng)站建設、域名、網(wǎng)頁空間、綿陽服務器托管、企業(yè)網(wǎng)站設計、南岸網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

文章標題:python模擬隊列和堆棧(列表練習)-創(chuàng)新互聯(lián)
文章網(wǎng)址:http://www.rwnh.cn/article22/csscjc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設、App開發(fā)網(wǎng)站設計公司、定制網(wǎng)站、網(wǎng)站內(nèi)鏈全網(wǎng)營銷推廣

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
日照市| 长乐市| 兴城市| 漳平市| 文化| 建平县| 安宁市| 韶山市| 长白| 巴楚县| 伊春市| 湘潭县| 汽车| 三亚市| 九江市| 日喀则市| 宁晋县| 黑山县| 菏泽市| 溧水县| 乳源| 景宁| 黄骅市| 页游| 苍梧县| 九江市| 广水市| 莒南县| 修武县| 通河县| 成安县| 嘉义市| 盐山县| 平湖市| 通山县| 新兴县| 威宁| 红安县| 正蓝旗| 天长市| 莱芜市|