1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      python模擬隊列和堆棧(列表練習)
      ##################################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()

      當前文章:python模擬隊列和堆棧(列表練習)
      網(wǎng)頁地址:http://www.ef60e0e.cn/article/gesoee.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        家居| 衢州市| 迭部县| 吴桥县| 开封县| 澄城县| 新民市| 南康市| 保靖县| 察隅县| 雅江县| 乌兰浩特市| 仙游县| 朔州市| 聂拉木县| 西和县| 双江| 嘉定区| 思南县| 新巴尔虎左旗| 乌苏市| 双江| 昌邑市| 四川省| 乐昌市| 凤城市| 成都市| 金秀| 临颍县| 高尔夫| 镇康县| 万州区| 商洛市| 海阳市| 农安县| 中牟县| 拜城县| 平原县| 河北省| 城市| 肃南|