<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>
    ???? Python ???
    ??9?? ?????
    ???? ?§Ò? ????

    ?§Ò?

    list?????????????????????????????????????§Ò??§Õ›¥??? ???? ???????????????????????§Ò?????????????????????????????????§Ò???????????????????????????????????????????§µ?????Python?§µ????????????????????þŸ

    ?§Ò??§Ö??????e???????????§µ?????Python??????????????????§Ò???????????????§Ò???????????????????????§Ò??§Ö??????????????????????????????????§Ò??? ???? ??????????????????????????????

    ????????????????

    ????????????????????????????????????????????????????????§Ò??????????????????????????????

    ?§Ò???????????????????????????????i?????????????????¿x????5????????????????????????????int?????????????i?????????????????help(int)??????????????

    ???????????????????????????????????????????????????????????????????§»????????íàPython?list??????append????????????????????§Ò?¦Â???????????????mylist.append('an item')?§Ò?mylist??????????????????????????????????????

    ?????????????????????????????????????????????????????????????????????§»????/??????????????????????mylist.field??

    ????§Ò?

    ??9.1 ????§Ò?

    #!/usr/bin/python
    # Filename: using_list.py

    # This is my shopping list

    shoplist = ['apple', 'mango', 'carrot', 'banana']

    print 'I have', len(shoplist),'items to purchase.'

    print 'These items are:', # Notice the comma at end of the line
    for item in shoplist:
        print item,

    print '\nI also have to buy rice.'
    shoplist.append('rice')
    print 'My shopping list is now', shoplist

    print 'I will sort my list now'
    shoplist.sort()
    print 'Sorted shopping list is', shoplist

    print 'The first item I will buy is', shoplist[0]
    olditem = shoplist[0]
    del shoplist[0]
    print 'I bought the', olditem
    print 'My shopping list is now', shoplist

    ????????code/using_list.py??

    ???

    $ python using_list.py
    I have 4 items to purchase.
    These items are: apple mango carrot banana
    I also have to buy rice.
    My shopping list is now ['apple', 'mango', 'carrot', 'banana', 'rice']
    I will sort my list now
    Sorted shopping list is ['apple', 'banana', 'carrot', 'mango', 'rice']
    The first item I will buy is apple
    I bought the apple
    My shopping list is now ['banana', 'carrot', 'mango', 'rice']

    ????¦É???

    ????shoplist??????????§Ò????shoplist?§µ???????›¥?????????????????????????????????????§Ò?????? ?¦Ê????????? ???????????????§Ò??

    ??????????for..in??????§Ò??§Ú???????î•????????????????????????§Ò??????????§³????§Ö??????????????????????

    ?????????print?????¦Â???????? ???? ?????????print?????????????§Ù??????????§Ö????????????????§¹??

    ???????????????append???????§Ò????????????????????????????????????????????????????§Ò??????????????????????????????§Ò????????§Ò?????????§Ò?????print?????????????????????????

    ?????????????????§Ò??sort?????????§Ò??????????????????????????§Ò???????????????????????§Ò??????????????????????????????????????????§Ò??? ???? ????????? ?????? ??

    ?????????????????§Ô???????????????????????????????§Ò???????????????del???????????????????????????????????????§Ò??§Ö???????????del??????????§Ò????????????????????????????§Ò??§Ö???????????????????del shoplist[0]???????Python??0???????????

    ????????????§Ò??????????§Ù????????????help(list)?????????????


    ???? ????? ????
    ??? ??? ???
    ?????
    @ssv 97av