posts - 431,  comments - 344,  trackbacks - 0
          公告
           Don't Repeat Yourself
          座右銘:you can lose your money, you can spent all of it, and if you work hard you get it all back. But if you waste your time, you're never gonna get it back.
          公告本博客在此聲明部分文章為轉摘,只做資料收集使用。


          微信: szhourui
          QQ:109450684
          Email
          lsi.zhourui@gmail.com
          <2009年6月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          留言簿(15)

          隨筆分類(1019)

          文章分類(3)

          文章檔案(21)

          收藏夾

          Link

          好友博客

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 860900
          • 排名 - 44

          最新評論

          閱讀排行榜

          python的set和其他語言類似, 是一個無序不重復元素集, 基本功能包括關系測試和消除重復元素. 集合對象還支持union(聯合), intersection(交), difference(差)和sysmmetric difference(對稱差集)等數學運算.

          >>> basket = [’apple’, ’orange’, ’apple’, ’pear’, ’orange’, ’banana’]
          >>> fruit = set(basket) # create a set without duplicates
          >>> fruit
          set([’orange’, ’pear’, ’apple’, ’banana’])
          >>> ’orange’ in fruit # fast membership testing
          True
          >>> ’crabgrass’ in fruit
          False
          >>> # Demonstrate set operations on unique letters from two words
          ...
          >>> a = set(’abracadabra’)
          >>> b = set(’alacazam’)
          >>> a # unique letters in a
          set([’a’, ’r’, ’b’, ’c’, ’d’])
          >>> a - b # letters in a but not in b
          set([’r’, ’d’, ’b’])
          >>> a | b # letters in either a or b
          set([’a’, ’c’, ’r’, ’d’, ’b’, ’m’, ’z’, ’l’])
          >>> a & b # letters in both a and b
          set([’a’, ’c’])
          >>> a ^ b # letters in a or b but not both
          set([’r’, ’d’, ’b’, ’m’, ’z’, ’l’])
          posted on 2009-06-02 21:24 周銳 閱讀(1028) 評論(0)  編輯  收藏 所屬分類: Python
          主站蜘蛛池模板: 乌鲁木齐县| 郁南县| 渑池县| 农安县| 伊金霍洛旗| 丹阳市| 威宁| 五华县| 满城县| 江安县| 清流县| 会宁县| 大安市| 邵东县| 斗六市| 岳西县| 重庆市| 台山市| 汕尾市| 富宁县| 西乡县| 莫力| 临潭县| 区。| 泸州市| 班戈县| 广南县| 台前县| 太湖县| 定日县| 武城县| 逊克县| 吉木萨尔县| 宕昌县| 广丰县| 双鸭山市| 奇台县| 赤峰市| 九龙坡区| 闸北区| 冷水江市|