Python基礎類型的基礎函數總結

來源:互聯網
上載者:User

標籤:list   dict   tuple   str相關   

#"""sets    """len+*find,replacesplitisalpha,isdigit,rstrip"%s"str    len(s)s[0],s[-1]    (raw)s = ‘sam‘    s = ‘S‘+s[1:]    print s            Sam    line= ‘aaa,bbb,ccc,ddd‘    print line.split(‘,‘)    line = line.split(‘,‘)    print line    "result":[‘aaa‘, ‘bbb‘, ‘ccc‘, ‘ddd‘]             [‘aaa‘, ‘bbb‘, ‘ccc‘, ‘ddd‘]    line= ‘aaa,bbb,ccc,ddd,\n‘    line = line.rstrip()##print line    aaa,bbb,ccc,ddd,    print ‘%s is %s‘ % (‘I‘, ‘you‘)    print ‘%s‘ % ‘you‘    I is you    you(...)    appendpop,sort,reverse,insert,        remove,rstrip....list    list"".joinlistlist1 = [1, 3, 4, 5, 5, 7]    print list1[0]    list1[0]=22    print list1    print list1[0:3:1] ##list1[begin:end:step]    base = [‘a‘, ‘b‘, 2.33, [‘a‘, ‘bc‘]]    base.append((‘abc‘,))    print base  ##base.append[‘a‘, ‘b‘, 2.33, [‘a‘, ‘bc‘], (‘abc‘,)]    base = [‘a‘, ‘b‘, 2.33, [‘a‘, ‘bc‘]]    base.append((‘abc‘,))   ##print base    base.pop(2)     ##print base    base.sort()     ##print base    base.reverse()  ##print base    [‘a‘, ‘b‘, 2.33, [‘a‘, ‘bc‘], (‘abc‘,)]    [‘a‘, ‘b‘, [‘a‘, ‘bc‘], (‘abc‘,)]    [[‘a‘, ‘bc‘], ‘a‘, ‘b‘, (‘abc‘,)]    [(‘abc‘,), ‘b‘, ‘a‘, [‘a‘, ‘bc‘]]  foriterable()res = [ord(x) for x in ‘spam‘] ##ord()ASCIIprint res    [115, 112, 97, 109]    [expression for target1 in iterable1 [if condition1]]..        for targetn in iterablen[if condition]        ifdef fun():    return [(x,y) for x in range(5) if x % 2 == 0 for   y in range(5) if y%2 ==1]    print fun()    [(0, 1), (0, 3), (2, 1), (2, 3), (4, 1), (4, 3)]D[key]Dkeyvalue,D.keys()DKeyKeyvalue,keyclear()keys()values(),items()D.get(key[,d])keyD[key],d,None    pop(key[,d])keykeyssortD = {‘a‘: 1, ‘b‘: 2}    print D    Ks = list(D.keys())    print Ks    Ks.reverse()    print Ks    for key in Ks:        print (key, ‘==>‘, D[key])    (‘b‘, ‘==>‘, 2)    (‘a‘, ‘==>‘, 1)tuple    T.index(4)  4T.count(4)  4tup1+tup2del tup,cmp(tup1,tup2)  len(tup)        max/min(tuple)      /,


Python基礎類型的基礎函數總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.