青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Welcome to 陳俊峰's ---BeetleHeaded Man Blog !

  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  58 隨筆 :: 32 文章 :: 18 評(píng)論 :: 0 Trackbacks
Python Reading Notes (2006-4-13) ?

Note One:about list (wow! so powerful)

Assignment to slices is also possible, and this can even change the size of the list,but you can not do that in the string type:
>>> # Replace some items:
... a[0:2] = [1, 12]
>>> a
[1, 12, 123, 1234]
>>> # Remove some:
... a[0:2] = []
>>> a
[123, 1234]
>>> # Insert some:
... a[1:1] = ['bletch', 'xyzzy']
>>> a
[123, 'bletch', 'xyzzy', 1234]
>>> a[:0] = a???? # Insert (a copy of) itself at the beginning
>>> a
[123, 'bletch', 'xyzzy', 1234, 123, 'bletch', 'xyzzy', 1234]

It is possible to nest lists (create lists containing other lists), for example:
>>> q = [2, 3]
>>> p = [1, q, 4]
>>> len(p)
3
>>> p[1]
[2, 3]
>>> p[1][0]
2
>>> p[1].append('xtra')????
>>> p
[1, [2, 3, 'xtra'], 4]
>>> q
[2, 3, 'xtra']


Note Two : about for statement

It is not safe to modify the sequence being iterated over in the loop (this can only happen for mutable sequence types, such as lists). If you need to modify the list you are iterating over (for example, to duplicate selected items) you must iterate over a copy. The slice notation makes this particularly convenient:

valid statements: it will work normally
>>> for x in a[:]: # make a slice copy of the entire list
...?????? if len(x) > 6:?
...???????????a.insert(0, x)
...
>>> a
['defenestrate', 'cat', 'window', 'defenestrate']

invalid statement: you prompt will die
>>> for x in a :? # make a slice copy of the entire list
...??? ???if len(x) > 6:
...????????? a.insert(0, x)
...

Note that: in the first statement?the first row ,the?for statement?ues 'a[:] ' ,it means that?to make a slice of?it;but in the second statement,the for statement ues 'a' directly ,so cause a?bad?result?

Note Three: Compare for efficiency

str_test = []
#?method one :
str_test.append('attach')
#method two:
str_test = str_test?+ ['attach']

The?Two?method above has the?same function ,but the more efficient one is the first one
?
Note Four :about Defining Functions?
Form 1:Default Argument Values
The default value is evaluated only once.
def f(a, L=[]):
??? L.append(a)
??? return L

print f(1)
print f(2)
print f(3)

This will print

[1]
[1, 2]
[1, 2, 3]

If you don't want the default to be shared between subsequent calls, you can write the function like this instead:

def f(a, L=None):
    if L is None:
        L = []
    L.append(a)
    return L

Form 2 : Keyword Arguments

When a final formal parameter of the form **name is present, it receives a dictionary containing all keyword arguments except
for those corresponding to a formal parameter. This may be combined with a formal parameter of the form *name (described in
the next subsection) which receives a tuple containing the positional arguments beyond the formal parameter list. (*name must
occur before **name) For example, if we define a function like this:

def cheeseshop(kind, *arguments, **keywords):
    print "-- Do you have any", kind, '?'
    print "-- I'm sorry, we're all out of", kind
    for arg in arguments: print arg
    print '-'*40
keys = keywords.keys() keys.sort() for kw in keys: print kw, ':', keywords[kw]

It could be called like this:

cheeseshop('Limburger', "It's very runny, sir.",
           "It's really very, VERY runny, sir.",
           client='John Cleese',
           shopkeeper='Michael Palin',
           sketch='Cheese Shop Sketch')

and of course it would print:

-- Do you have any Limburger ?
-- I'm sorry, we're all out of Limburger
It's very runny, sir.
It's really very, VERY runny, sir.
----------------------------------------
client : John Cleese
shopkeeper : Michael Palin
sketch : Cheese Shop Sketch

Note that the sort() method of the list of keyword argument names is called before printing the contents of the keywords
dictionary; if this is not done, the order in which the arguments are printed is undefined.

posted on 2006-04-13 10:50 Jeff-Chen 閱讀(168) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Python
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲激情在线激情| 亚洲免费大片| 国产精品久久久久一区二区三区| 亚洲欧美在线看| 亚洲一区二区精品在线观看| 99精品国产高清一区二区| 久久全国免费视频| 欧美一区91| 欧美一区二区三区四区高清 | 久久综合一区二区| 激情文学一区| 国产农村妇女毛片精品久久麻豆 | 国产综合欧美| 精品51国产黑色丝袜高跟鞋| 亚洲国产mv| 亚洲一区国产一区| 久久久久久久国产| 亚洲国产精品久久久久婷婷老年| 亚洲大片在线| 亚洲桃色在线一区| 欧美怡红院视频| 欧美成人免费播放| 欧美好骚综合网| 国产精品人成在线观看免费| 国产亚洲精品v| 亚洲精品黄色| 亚洲欧美美女| 农夫在线精品视频免费观看| 99精品99| 麻豆精品视频在线观看| 欧美午夜精品久久久久久久| 国产亚洲欧洲一区高清在线观看| 亚洲人成在线观看| 欧美影院在线| 日韩午夜av电影| 久久精品五月婷婷| 国产精品久久99| 亚洲黄色免费| 久久久久国产精品麻豆ai换脸| 亚洲经典在线看| 欧美一级大片在线观看| 欧美日本亚洲韩国国产| 国产日韩精品在线观看| 一区二区三区精品视频在线观看| 久久躁日日躁aaaaxxxx| 亚洲视频你懂的| 欧美激情视频免费观看| 欧美亚洲一区二区在线| 国产亚洲欧美色| 亚洲一区二区免费看| 欧美黄色影院| 久久蜜桃资源一区二区老牛 | 亚洲国产专区校园欧美| 欧美高清在线精品一区| 一区二区三区亚洲| 亚洲在线观看免费视频| 亚洲二区视频在线| 欧美制服第一页| 国产乱码精品一区二区三区忘忧草 | 欧美成ee人免费视频| 性欧美办公室18xxxxhd| 国产精品毛片va一区二区三区| 亚洲精品视频在线观看网站 | 日韩一级不卡| 亚洲国产一区二区三区高清 | 国产精品成人观看视频国产奇米| 亚洲欧洲中文日韩久久av乱码| 久久精品国产精品亚洲| 亚洲午夜成aⅴ人片| 欧美亚洲成人精品| 亚洲视频1区2区| 亚洲精品一区在线观看香蕉| 久久综合给合久久狠狠色| 尹人成人综合网| 久久精品国产久精国产思思| 欧美亚洲自偷自偷| 在线色欧美三级视频| 欧美成人一区二区| 欧美成人国产va精品日本一级| 亚洲国产合集| 亚洲国产欧美精品| 欧美日韩精品三区| 亚洲婷婷免费| 国产一区免费视频| 欧美在线精品一区| 亚洲国产精品专区久久| 最新国产成人av网站网址麻豆| 欧美激情一区二区三区在线视频观看| 亚洲开发第一视频在线播放| 日韩亚洲欧美在线观看| 国产伦精品一区二区三区高清 | 亚洲国产天堂久久综合| 亚洲激情一区| 国产精品久久综合| 久久综合网色—综合色88| 久久综合狠狠综合久久综合88| 日韩视频免费在线观看| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 宅男66日本亚洲欧美视频| 亚洲一本视频| 国产欧美综合在线| 奶水喷射视频一区| 亚洲欧美在线免费| 亚洲日本黄色| 国产一区二区成人| 91久久精品国产91久久性色| 国产精品一区二区视频| 欧美在线一二三区| 久久精品国产一区二区三| 亚洲美女在线看| 一本大道久久a久久综合婷婷| 国产亚洲成av人在线观看导航| 亚洲高清不卡av| 国产欧美1区2区3区| 亚洲精品免费电影| 国产综合视频| 国产精品99久久久久久有的能看| 亚洲电影激情视频网站| 亚洲一区3d动漫同人无遮挡| 精品1区2区3区4区| 欧美一级专区| 欧美亚洲视频一区二区| 久热精品视频在线观看一区| 欧美一区二区三区电影在线观看| 欧美精品亚洲一区二区在线播放| 久久精品成人欧美大片古装| 欧美高清在线视频观看不卡| 国产日韩欧美视频| 日韩亚洲一区二区| 亚洲国产成人精品久久| 欧美在线影院| 久久久综合网站| 国产热re99久久6国产精品| 99香蕉国产精品偷在线观看| 久久婷婷丁香| 噜噜噜噜噜久久久久久91 | 久久精品中文| 午夜久久tv| 欧美人在线视频| 亚洲日本aⅴ片在线观看香蕉| 国产一区二区中文字幕免费看| 亚洲视频在线二区| 9色精品在线| 欧美国产日韩精品免费观看| 欧美福利一区二区三区| 亚洲国产裸拍裸体视频在线观看乱了中文 | 99热在这里有精品免费| 久久精品国产精品| 欧美一区二区视频在线观看| 一本色道久久综合狠狠躁篇怎么玩| 免费永久网站黄欧美| 欧美承认网站| 亚洲精品三级| 欧美四级在线观看| 亚洲天天影视| 亚洲欧美日韩天堂一区二区| 亚洲国产91| 亚洲精品在线视频观看| 欧美日韩高清在线一区| 亚洲视频www| 久久女同互慰一区二区三区| 影音国产精品| 国产农村妇女精品一区二区| 亚洲精品美女久久7777777| 亚洲精品亚洲人成人网| 亚洲国产第一页| 国产精品免费观看在线| 亚洲欧美激情精品一区二区| 欧美一级视频精品观看| 国产在线观看精品一区二区三区| 久久精品国产一区二区三区免费看| 蜜桃av综合| 日韩午夜高潮| 国产精品日韩精品欧美在线| 亚洲欧美日韩综合国产aⅴ| 欧美韩日一区二区三区| 麻豆91精品| 欧美在线|欧美| 美女图片一区二区| 欧美黄色网络| 欧美日韩精品系列| 亚洲人成免费| 精品成人久久| 欧美女主播在线| 午夜一级在线看亚洲| 欧美激情亚洲精品| 小处雏高清一区二区三区| 亚洲国产精品一区二区第四页av| 欧美视频一区二区三区| 久久久久久穴| 亚洲欧美一区二区三区在线| 亚洲国产精选| 久久精品人人做人人综合 | 亚洲国产一区二区视频| 亚洲欧美日韩久久精品| 欧美大片91| 亚洲综合精品自拍| 亚洲日本中文字幕区| 久久综合久色欧美综合狠狠| 亚洲一区二区三区三|