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

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

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  58 隨筆 :: 32 文章 :: 18 評論 :: 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 閱讀(170) 評論(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>
            国产日韩成人精品| 国产精品va在线| 欧美不卡视频一区| 国产精品日韩高清| 99国产一区| 欧美大成色www永久网站婷| 亚洲一区免费观看| 欧美日本网站| 一区二区黄色| 91久久精品视频| 久久日韩粉嫩一区二区三区| 国产欧美一区二区三区视频| 香蕉免费一区二区三区在线观看 | 午夜精品福利视频| 国产精品狠色婷| 中国亚洲黄色| 99精品视频免费在线观看| 欧美日韩精品免费观看视频| 一本一本久久| 一区二区三区 在线观看视频| 欧美三级乱人伦电影| 亚洲女爱视频在线| 午夜精品网站| 激情久久久久久久| 亚洲国产精品小视频| 欧美高清一区二区| 亚洲私人影院| 亚洲一区二区精品在线观看| 国产精品一区二区久激情瑜伽| 欧美中文字幕在线| 久久久久久久性| 亚洲乱码国产乱码精品精98午夜| 亚洲日韩欧美视频| 国产精品国产三级国产专播品爱网| 亚洲男女毛片无遮挡| 欧美一区二区三区四区在线 | 国产亚洲二区| 蜜臀av性久久久久蜜臀aⅴ| 久久综合伊人77777蜜臀| 亚洲精品日本| 亚洲一区免费看| 亚洲高清免费| 亚洲精品国产品国语在线app| 国产精品高精视频免费| 久久久久综合网| 欧美日韩国产一区二区| 久久99伊人| 欧美福利电影在线观看| 欧美一区二区免费| 欧美高清不卡在线| 欧美一区二区三区成人 | 亚洲精品视频一区| 亚洲欧美日韩第一区| 亚洲韩国青草视频| 国内外成人在线视频| 日韩午夜剧场| 欧美一级午夜免费电影| 亚洲国产另类 国产精品国产免费| 日韩视频精品在线| 激情偷拍久久| 一本色道婷婷久久欧美| 在线成人av.com| 宅男噜噜噜66一区二区| 在线观看视频亚洲| 亚洲欧美不卡| 9l视频自拍蝌蚪9l视频成人| 久久精品二区三区| 亚洲午夜精品网| 米奇777超碰欧美日韩亚洲| 欧美一区二区三区免费观看视频| 欧美风情在线| 久热精品在线| 国产日韩欧美麻豆| 一区二区三区日韩| 亚洲免费精品| 免费观看国产成人| 久久久噜噜噜| 国产一区二区三区四区三区四| 亚洲视频播放| 亚洲一级黄色| 欧美日韩一区二区三区| 亚洲黄色天堂| 亚洲激情成人网| 久久精品国产亚洲a| 欧美一区亚洲| 国产精品美女黄网| 在线一区二区视频| 在线视频欧美日韩精品| 欧美人在线观看| 99精品国产在热久久下载| 亚洲精品一区二区网址| 欧美高清在线一区| 欧美福利视频一区| 亚洲日韩中文字幕在线播放| 女同一区二区| 欧美激情欧美激情在线五月| 1769国产精品| 久热国产精品| 亚洲国产视频a| 日韩午夜黄色| 欧美喷水视频| 一本综合精品| 亚洲一区中文字幕在线观看| 国产精品美女久久久久久免费| 亚洲午夜在线| 久久精品99国产精品酒店日本| 国产揄拍国内精品对白| 久久精品国产一区二区电影| 免费观看在线综合| 一区二区欧美视频| 国产精品日本一区二区| 欧美一区国产在线| 欧美高清视频在线播放| 一本色道久久| 国产老女人精品毛片久久| 性欧美大战久久久久久久免费观看| 久久国产一区| 亚洲人成亚洲人成在线观看| 欧美日韩三级电影在线| 午夜一级久久| 欧美激情2020午夜免费观看| 亚洲视频axxx| 尤物网精品视频| 欧美日韩视频| 亚洲精品四区| 欧美午夜视频网站| 久久精品72免费观看| 亚洲精选一区二区| 久久福利电影| 亚洲靠逼com| 国产精品乱人伦一区二区| 久久动漫亚洲| 日韩网站免费观看| 久久综合综合久久综合| 亚洲色图在线视频| 国模精品娜娜一二三区| 欧美日韩国产成人在线免费| 欧美一区二区网站| 99人久久精品视频最新地址| 老司机一区二区| 欧美一区午夜视频在线观看| 一区二区三区国产盗摄| 亚洲大胆av| 国产欧美一区二区三区久久| 欧美日韩国产在线观看| 久久天天躁狠狠躁夜夜av| 中国av一区| 亚洲人永久免费| 久久一区激情| 欧美一级二区| 一区二区三区 在线观看视频| 国产婷婷色综合av蜜臀av| 欧美日韩伦理在线免费| 久久久999成人| 亚洲在线免费视频| 亚洲国产日韩欧美在线99| 久久免费精品视频| 欧美在线免费视屏| 亚洲一区尤物| 日韩午夜电影在线观看| 在线 亚洲欧美在线综合一区| 国产精品久久夜| 欧美日韩亚洲一区三区 | 亚洲精品免费在线| 一区二区视频免费在线观看 | 一区二区国产精品| 最新日韩在线| 在线免费精品视频| 亚洲成人在线| 在线免费观看日本欧美| 一区二区视频在线观看| 国产一区二区三区成人欧美日韩在线观看 | 久久久免费精品视频| 欧美在线一二三四区| 亚洲欧美经典视频| 亚洲一区二区在线免费观看视频| 9人人澡人人爽人人精品| 亚洲精品免费在线| 亚洲精品国产欧美| 99精品热视频只有精品10| 99视频+国产日韩欧美| 一区二区三区四区国产精品| 一区二区三区视频观看| 一区二区三区.www| 中文国产亚洲喷潮| 亚洲一区二区三区精品动漫| 亚洲一区二区在线看| 香蕉久久夜色精品国产使用方法| 午夜精品福利一区二区蜜股av| 欧美一区二区三区在线免费观看 | 国产一区二区0| 激情久久影院| 亚洲欧洲在线免费| 亚洲图片欧美午夜| 欧美成人午夜免费视在线看片| 亚洲成人资源| 一本色道久久综合亚洲精品高清| 一区二区精品在线| 欧美一区二区在线观看| 久久久综合香蕉尹人综合网|