python涓栫晫level2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python涓栫晫level2相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e9%85%8d%e7%bd%ae' title='閰嶇疆'>閰嶇疆
integer listen readline 甯哥敤 浣滅敤 蹇樿 涓夌骇 beyondlevel2
鏈骇鍒富瑕佹帉鎻″嚑椤瑰熀鏈妧鑳斤紱
- 鍒楄〃銆佸厓缁勬搷浣?/li>
- 瀛楃涓叉搷浣?/li>
- 瀛楀吀鎿嶄綔
- 闆嗗悎鎿嶄綔
- 鏂囦欢鎿嶄綔
- 瀛楃缂栫爜涓庤浆鐮?/li>
鍒楄〃涓庡厓缁勬搷浣?/p>
銆€銆€
#!/usr/bin/env python #Author:Ponke91 names=["zhangyang","lisi","lisi","lisi","lisi","lisi","wangsan"] names.append("leidongl") names.insert(1,"lisansan") print(names) print(names[1],names[2]) print(names[1:3])#鍒楄〃鍒囩墖椤惧ご涓嶉【灏? print(len(names)) print(names[-1]) print(names[-3:-2]) names.pop()#鍒犻櫎 names.sort()#鎺掑簭锛屾寜鐓Scall鐮佸€? names.extend(names)#鍚堝苟 print(names.index("lisi"))#绱㈠紩 print(names.count("lisi")) names.reverse()#鍙嶈浆 names.insert(2,["123","23424"]) #names_old=names.copy()#娴卌opy锛屽彧鏄痗opy绱㈠紩锛屽鍒跺唴瀛樺湴鍧€锛屽彧copy绗竴灞傚苟鍏嬮殕 #濡傛灉闇€瑕佸畬鏁碿opy鎵€鏈夊唴瀛樻暟鎹€屼笉鏄寚閽堝湴鍧€锛岄渶瑕乮mport copy 妯″潡 import copy print(names) names_old=copy.deepcopy(names)#娣眂opy鐩稿綋浜庣‖閾炬帴 names[2][0]="AAA" print(names) print(names_old) #for i in names_old: # print(i) print(names_old[0::2])
瀛楃涓叉搷浣?/p>
1 #!/usr/bin/env python 2 #Author:Ponke91 3 name="my name is {name1},{age}" 4 print(name.capitalize())#棣栧瓧姣嶅ぇ鍐?/span> 5 print(name.count("o"))#缁熻瀛楃涓蹭腑鍏冪礌鍑虹幇寰楁鏁?/span> 6 print(name.center(50,"-"))#鎵撳嵃鍦?0涓瓧绗﹀緱涓棿浣嶇疆锛屽叾浣欑┖鐧藉瓧绗︾敤“-”鏇夸唬 7 print(name.endswith("91"))#妫€鏌ュ瓧绗︿覆寰楃粨灏炬柟寮?/span> 8 print(name.expandtabs(tabsize=30)) 9 print(name[name.find("name"):9]) 10 print(name.format(name1=鈥?/span>ponke91鈥?/span>,age=99))#鏍煎紡鍖?/span> 11 print(name.format_map({鈥?/span>name1鈥?/span>:鈥?/span>ponke91鈥?/span>,鈥?/span>age鈥?/span>:99}))#瀛楀吀鏍煎紡鍖?/span> 12 print(name.isalnum())#绾樋鎷変集鏁板瓧瀛楁瘝+鏁板瓧 13 print(name.isalpha())#绾嫳鏂囧瓧绗?/span> 14 print(name.isdigit())#鏁存暟 15 print(name.isidentifier())#鏄笉鏄竴涓悎娉曠殑鍙橀噺鍚?/span> 16 print("1".isnumeric())#鏄笉鏄竴涓嚜鐒舵暟 17 print(name.isspace())#鏄笉鏄竴涓┖鐧?/span> 18 print(name.istitle()) 19 print(name.isprintable())#鍒ゆ柇鏄惁鍙互鎵撳嵃锛岄┍鍔ㄧ▼搴弍py 20 print(name.isupper())#鏄笉鏄ぇ鍐?/span> 21 print("[鈥?鈥?2,3]".join([鈥?/span>1鈥?/span>,鈥?/span>2鈥?/span>,鈥?/span>3鈥?/span>]))#灏嗗垪琛ㄤ綔涓哄瓧绗︿覆鎵撳嵃 22 print(name.ljust(50,鈥?/span>$鈥?/span>))#宸﹁竟濉弧 23 print(name.rjust(40,鈥?/span>#鈥?/span>))#鍙宠竟濉弧 24 print(name.lower())#鎵€鏈夊瓧绗﹀叏閮ㄥ皬鍐?/span> 25 print(name.upper())#鎵€鏈夊瓧绗﹀叏閮ㄥぇ鍐?/span> 26 print(name.strip())#鍘绘帀鎵€鏈夌殑绌烘牸 鍥炶溅 27 print(name.lstrip())#宸﹁竟鍘绘帀绌烘牸鍥炶溅 28 print(name.rstrip())#鍙宠竟鍘绘帀绌烘牸鍥炶溅 29 names="ponke91" 30 p=str.maketrans("qwepksr",鈥?/span>1234567鈥?/span>) 31 print(names.translate(p)) 32 print(name.replace(鈥?/span>a鈥?/span>,鈥?/span>A鈥?/span>,2))#鏇挎崲 33 print(name.rfind(鈥?/span>a鈥?/span>))#浠庡彸杈瑰鎵?/span> 34 print(name.split())#灏嗗瓧绗︿覆鍒嗗壊鎴愬垪琛?/span> 35 print(name.splitlines())#灏嗗瓧绗︿覆鎸夌収鎹㈣鏉ュ尯鍒?/span> 36 print(name.swapcase())#鍙嶈浆瀛楃澶у皬鍐?/span> 37 print(name.title())#棣栧瓧姣嶅ぇ鍐?/span> 38 print(name.zfill(50))#鐢?濉厖
瀛楀吀鎿嶄綔
1 #!/usr/bin/env python 2 #Author:Ponke91 3 鈥樷€樷€?/span>娑堥槻鏁戞彺琛旈珮鐨勪汉鍛樺娑堥槻鏁戞彺琛斾綆鐨勪汉鍛橈紝娑堥槻鏁戞彺琛旈珮鐨勪负涓婄骇銆傚綋娑堥槻鏁戞彺琛旈珮鐨勪汉鍛橀毝灞炰簬娑堥槻鏁戞彺琛斾綆鐨勪汉鍛樻椂锛屾媴浠婚瀵艰亴鍔$殑鎴栬€呴瀵艰亴鍔¢珮鐨勪负涓婄骇銆傛秷闃叉晳鎻磋鎸夌収绠$悊鎸囨尌骞查儴銆佷笓涓氭妧鏈共閮ㄥ拰娑堥槻鍛樺垎鍒缃€? 4 绠$悊鎸囨尌骞查儴娑堥槻鏁戞彺琛旇涓嬪垪涓夌瓑鍗佷竴绾э細 5 銆€銆€锛堜竴锛夋€荤洃銆佸壇鎬荤洃銆佸姪鐞嗘€荤洃锛? 6 銆€銆€锛堜簩锛夋寚鎸ラ暱锛氶珮绾ф寚鎸ラ暱銆佷竴绾ф寚鎸ラ暱銆佷簩绾ф寚鎸ラ暱銆佷笁绾ф寚鎸ラ暱锛? 7 銆€銆€锛堜笁锛夋寚鎸ュ憳锛氫竴绾ф寚鎸ュ憳銆佷簩绾ф寚鎸ュ憳銆佷笁绾ф寚鎸ュ憳銆佸洓绾ф寚鎸ュ憳銆? 8 銆€銆€涓撲笟鎶€鏈共閮ㄦ秷闃叉晳鎻磋璁句笅鍒椾袱绛夊叓绾э紝鍦ㄦ秷闃叉晳鎻磋鍓嶅啝浠?ldquo;涓撲笟鎶€鏈?rdquo;锛? 9 銆€銆€锛堜竴锛夋寚鎸ラ暱锛氶珮绾ф寚鎸ラ暱銆佷竴绾ф寚鎸ラ暱銆佷簩绾ф寚鎸ラ暱銆佷笁绾ф寚鎸ラ暱锛? 10 銆€銆€锛堜簩锛夋寚鎸ュ憳锛氫竴绾ф寚鎸ュ憳銆佷簩绾ф寚鎸ュ憳銆佷笁绾ф寚鎸ュ憳銆佸洓绾ф寚鎸ュ憳銆? 11 銆€銆€娑堥槻鍛樻秷闃叉晳鎻磋璁句笅鍒椾笁绛夊叓绾э細 12 銆€銆€锛堜竴锛夐珮绾ф秷闃插憳锛氫竴绾ф秷闃查暱銆佷簩绾ф秷闃查暱銆佷笁绾ф秷闃查暱锛? 13 銆€銆€锛堜簩锛変腑绾ф秷闃插憳锛氫竴绾ф秷闃插+銆佷竴绾ф秷闃插+锛? 14 銆€銆€锛堜笁锛夊垵绾ф秷闃插憳锛氫笁绾ф秷闃插+銆佸洓绾ф秷闃插+銆侀澶囨秷闃插+銆?/span>鈥樷€樷€?/span> 15 Commander={ 16 鈥?/span>绠$悊鎸囨尌骞查儴鈥?/span>:{ 17 鈥?/span>鎬荤洃鈥?/span>:[鈥?/span>鎬荤洃鈥?/span>, 鈥?/span>鍓€荤洃鈥?/span>, 鈥?/span>鍔╃悊鎬荤洃鈥?/span>], 18 鈥?/span>鎸囨尌闀?/span>鈥?/span>:[鈥?/span>楂樼骇鎸囨尌闀?/span>鈥?/span>, 鈥?/span>涓€绾ф寚鎸ラ暱鈥?/span>, 鈥?/span>浜岀骇鎸囨尌闀?/span>鈥?/span>, 鈥?/span>涓夌骇鎸囨尌闀?/span>鈥?/span>], 19 鈥?/span>鎸囨尌鍛?/span>鈥?/span>:[鈥?/span>涓€绾ф寚鎸ュ憳鈥?/span>, 鈥?/span>浜岀骇鎸囨尌鍛?/span>鈥?/span>, 鈥?/span>涓夌骇鎸囨尌鍛?/span>鈥?/span>, 鈥?/span>鍥涚骇鎸囨尌鍛?/span>鈥?/span>]}, 20 鈥?/span>涓撲笟鎶€鏈共閮?/span>鈥?/span>:{ 21 鈥?/span>鎸囨尌闀?/span>鈥?/span>:[鈥?/span>楂樼骇鎸囨尌闀?/span>鈥?/span>,鈥?/span>涓€绾ф寚鎸ラ暱鈥?/span>,鈥?/span>浜岀骇鎸囨尌闀?/span>鈥?/span>,鈥?/span>涓夌骇鎸囨尌闀?/span>鈥?/span>], 22 鈥?/span>鎸囨尌鍛?/span>鈥?/span>:[鈥?/span>涓€绾ф寚鎸ュ憳鈥?/span>,鈥?/span>浜岀骇鎸囨尌鍛?/span>鈥?/span>,鈥?/span>涓夌骇鎸囨尌鍛?/span>鈥?/span>,鈥?/span>鍥涚骇鎸囨尌鍛?/span>鈥?/span>]}, 23 鈥?/span>娑堥槻鍛?/span>鈥?/span>:{ 24 鈥?/span>娑堥槻闀?/span>鈥?/span>:[鈥?/span>涓€绾ф秷闃查暱鈥?/span>, 鈥?/span>浜岀骇娑堥槻闀?/span>鈥?/span>, 鈥?/span>涓夌骇娑堥槻闀?/span>鈥?/span>], 25 鈥?/span>娑堥槻澹?/span>鈥?/span>:[鈥?/span>涓€绾ф秷闃插+鈥?/span>, 鈥?/span>浜岀骇娑堥槻澹?/span>鈥?/span>], 26 鈥?/span>娑堥槻澹?鈥?/span>:[鈥?/span>涓夌骇娑堥槻澹?/span>鈥?/span>, 鈥?/span>鍥涚骇娑堥槻澹?/span>鈥?/span>, 鈥?/span>棰勫娑堥槻澹?/span>鈥?/span>]}} 27 flag=False 28 while not flag: 29 for i in Commander: 30 print(i) 31 choice=input("閫夋嫨杩涘叆绗竴灞傦細") 32 if choice in Commander: 33 while not flag: 34 for n in Commander[choice]: 35 print(鈥?/span> 鈥?/span>,n) 36 choice2=input("閫夋嫨杩涘叆绗簩灞傦細") 37 if choice2 in Commander[choice]: 38 while not flag: 39 for s in Commander[choice][choice2]: 40 print(s) 41 choice3=input("閫夋嫨杩涘叆绗笁灞傦細") 42 if choice3==鈥?/span>b鈥?/span>: 43 break 44 elif choice3==鈥?/span>q鈥?/span>: 45 flag=True 46 if choice2==鈥?/span>b鈥?/span>: 47 break 48 elif choice2== 鈥?/span>q鈥?/span>: 49 flag = True 50 if choice == 鈥?/span>b鈥?/span>: 51 break 52 elif choice == 鈥?/span>q鈥?/span>: 53 flag = True
1 #!/usr/bin/env python 2 #Author:Ponke91 3 xiaozi={ 4 鈥?/span>stu001鈥?/span>:鈥?/span>001鈥?/span>, 5 鈥?/span>stu002鈥?/span>:鈥?/span>003鈥?/span>, 6 鈥?/span>stu004鈥?/span>:3, 7 鈥?/span>stu005鈥?/span>:[鈥?/span>1鈥?/span>,鈥?/span>2鈥?/span>] 8 9 } 10 print(xiaozi[鈥?/span>stu005鈥?/span>]) 11 xiaozi[鈥?/span>stu002鈥?/span>]=鈥?/span>濂ヨ开鈥?/span> 12 13 del xiaozi[鈥?/span>stu001鈥?/span>] 14 xiaozi.pop("stu004")#鍒犻櫎 15 #xiaozi.popitem()#闅忔満鍒犻櫎 16 print(xiaozi) 17 print(xiaozi.get("stu005")) 18 print("stu006" in xiaozi) 19 xiaozi.values()#鎵€鏈夌殑鍊?/span> 20 xiaozi.setdefault("鍙版咕",{鈥?/span>www.baidu.com鈥?/span>:[1,2]})#浣跨敤鏂瑰紡鍦ㄥ瓧鍏镐腑鏌ユ壘鏄惁瀛樺湪璇ュ€硷紝濡傛灉瀛樺湪涓嶄慨鏀圭洿鎺ヨ繑鍥炶鍊硷紝濡傛灉涓嶅瓨鍦ㄥ垯淇敼 21 xxx={鈥?/span>zhangsan鈥?/span>:鈥?/span>lsi鈥?/span>,鈥?/span>afjals鈥?/span>:鈥?/span>111鈥?/span>} 22 xiaozi.update(xxx)#鍚堝苟涓や釜鍒楄〃锛岄噸澶嶇殑鍊间娇鐢╔XX鏇存柊锛屾病鏈夌殑鍊艰繘琛屽垱寤?/span> 23 xiaozi.items() 24 print(xiaozi.items())#瀛楀吀杞崲鎴愬垪琛?/span> 25 t=dict.fromkeys([鈥?/span>1鈥?/span>,鈥?/span>2鈥?/span>,鈥?/span>3鈥?/span>],鈥?/span>oooo鈥?/span>)#鍒濆鍖栦竴涓瓧鍏?鍐呭瓨鍦板潃涓嶅彲鍙?/span> 26 print(t)
鍏冪粍
1 #!/usr/bin/env python 2 #Author:Ponke91 3 4 Tuple=("ponke",鈥?/span>dd鈥?/span>,鈥?/span>33141鈥?/span>)#鍏冪粍涓嶅彲鍙樺彧鏈?锛屽父鐢ㄦ潵浣滀负閲嶈鍙傛暟涓嶅彲鍙?/span> 5 print(Tuple.count("ponke"))#count 缁熻 6 print(Tuple.index(鈥?/span>dd鈥?/span>))#锛宨ndex 鑾峰彇涓嬫爣
鍙傝€冪綉鍧€ https://www.cnblogs.com/alex3714/articles/5717620.html
闆嗗悎鎿嶄綔
銆€銆€
闆嗗悎鏄竴涓棤搴忕殑锛屼笉閲嶅鐨勬暟鎹粍鍚堬紝瀹冪殑涓昏浣滅敤濡備笅锛?/p>
- 鍘婚噸锛屾妸涓€涓垪琛ㄥ彉鎴愰泦鍚堬紝灏辫嚜鍔ㄥ幓閲嶄簡
- 鍏崇郴娴嬭瘯锛屾祴璇曚袱缁勬暟鎹箣鍓嶇殑浜ら泦銆佸樊闆嗐€佸苟闆嗙瓑鍏崇郴
甯哥敤鎿嶄綔
s = set([3,5,9,10]) #鍒涘缓涓€涓暟鍊奸泦鍚? t = set("Hello") #鍒涘缓涓€涓敮涓€瀛楃鐨勯泦鍚? a = t | s # t 鍜?s鐨勫苟闆? b = t & s # t 鍜?s鐨勪氦闆? c = t – s # 姹傚樊闆嗭紙椤瑰湪t涓紝浣嗕笉鍦╯涓級 d = t ^ s # 瀵圭О宸泦锛堥」鍦╰鎴杝涓紝浣嗕笉浼氬悓鏃跺嚭鐜板湪浜岃€呬腑锛? 鍩烘湰鎿嶄綔锛? t.add(鈥?/span>x鈥?/span>) # 娣诲姞涓€椤? s.update([10,37,42]) # 鍦╯涓坊鍔犲椤? 浣跨敤remove()鍙互鍒犻櫎涓€椤癸細 t.remove(鈥?/span>H鈥?/span>) len(s) set 鐨勯暱搴? x in s 娴嬭瘯 x 鏄惁鏄?s 鐨勬垚鍛? x not in s 娴嬭瘯 x 鏄惁涓嶆槸 s 鐨勬垚鍛? s.issubset(t) s <= t 娴嬭瘯鏄惁 s 涓殑姣忎竴涓厓绱犻兘鍦?t 涓? s.issuperset(t) s >= t 娴嬭瘯鏄惁 t 涓殑姣忎竴涓厓绱犻兘鍦?s 涓? s.union(t) s | t 杩斿洖涓€涓柊鐨?set 鍖呭惈 s 鍜?t 涓殑姣忎竴涓厓绱? s.intersection(t) s & t 杩斿洖涓€涓柊鐨?set 鍖呭惈 s 鍜?t 涓殑鍏叡鍏冪礌 s.difference(t) s - t 杩斿洖涓€涓柊鐨?set 鍖呭惈 s 涓湁浣嗘槸 t 涓病鏈夌殑鍏冪礌 s.symmetric_difference(t) s ^ t 杩斿洖涓€涓柊鐨?set 鍖呭惈 s 鍜?t 涓笉閲嶅鐨勫厓绱? s.copy() 杩斿洖 set “s”鐨勪竴涓祬澶嶅埗
5鏂囦欢鎿嶄綔
瀵规枃浠舵搷浣滄祦绋?/strong>
- 鎵撳紑鏂囦欢锛屽緱鍒版枃浠跺彞鏌勫苟璧嬪€肩粰涓€涓彉閲?/li>
- 閫氳繃鍙ユ焺瀵规枃浠惰繘琛屾搷浣?/li>
- 鍏抽棴鏂囦欢
鐜版湁鏂囦欢濡備笅
Somehow, it seems the love I knew was always the most destructive kind 涓嶇煡涓轰綍锛屾垜缁忓巻鐨勭埍鎯呮€绘槸鏈€鍏锋瘉鐏€х殑鐨勯偅绉? Yesterday when I was young 鏄ㄦ棩褰撴垜骞村皯杞荤媯 The taste of life was sweet 鐢熷懡鐨勬粙鍛虫槸鐢滅殑 As rain upon my tongue 灏卞鑸屽皷涓婄殑闆ㄩ湶 I teased at life as if it were a foolish game 鎴戞垙寮勭敓鍛?瑙嗗叾涓烘剼锠㈢殑娓告垙 The way the evening breeze 灏卞澶滄櫄鐨勫井椋? May tease the candle flame 閫楀紕铚$儧鐨勭伀鑻? The thousand dreams I dreamed 鎴戞浘鍗冧竾娆℃ⅵ瑙? The splendid things I planned 閭d簺鎴戣鍒掔殑缁氫附钃濆浘 I always built to last on weak and shifting sand 浣嗘垜鎬绘槸灏嗕箣寤虹瓚鍦ㄦ槗閫濈殑娴佹矙涓? I lived by night and shunned the naked light of day 鎴戝澶滅瑱姝?閫冮伩鐧芥樇璧よ8鐨勯槼鍏? And only now I see how the time ran away 浜嬪埌濡備粖鎴戞墠鐪嬫竻宀佹湀鏄浣曞寙鍖嗘祦閫? Yesterday when I was young 鏄ㄦ棩褰撴垜骞村皯杞荤媯 So many lovely songs were waiting to be sung 鏈夐偅涔堝鐢滅編鐨勬洸鍎跨瓑鎴戞瓕鍞? So many wild pleasures lay in store for me 鏈夐偅涔堝鑲嗘剰鐨勫揩涔愮瓑鎴戜韩鍙? And so much pain my eyes refused to see 杩樻湁閭d箞澶氱棝鑻?鎴戠殑鍙岀溂鍗磋鑰屼笉瑙? I ran so fast that time and youth at last ran out 鎴戦蹇湴濂旇蛋 鏈€缁堟椂鍏変笌闈掓槬娑堥€濇畣灏? I never stopped to think what life was all about 鎴戜粠鏈仠涓嬭剼姝ュ幓鎬濊€冪敓鍛界殑鎰忎箟 And every conversation that I can now recall 濡備粖鍥炴兂璧风殑鎵€鏈夊璇? Concerned itself with me and nothing else at all 闄や簡鍜屾垜鐩稿叧鐨?浠€涔堥兘璁颁笉寰椾簡 The game of love I played with arrogance and pride 鎴戠敤鑷礋鍜屽偛鎱㈢帺鐫€鐖辨儏鐨勬父鎴? And every flame I lit too quickly, quickly died 鎵€鏈夋垜鐐圭噧鐨勭伀鐒伴兘鐔勭伃寰楀お蹇? The friends I made all somehow seemed to slip away 鎵€鏈夋垜浜ょ殑鏈嬪弸浼间箮閮戒笉鐭ヤ笉瑙夊湴绂诲紑浜? And only now I鈥?/span>m left alone to end the play, yeah 鍙墿鎴戜竴涓汉鍦ㄥ彴涓婃潵缁撴潫杩欏満闂瑰墽 Oh, yesterday when I was young 鍣?鏄ㄦ棩褰撴垜骞村皯杞荤媯 So many, many songs were waiting to be sung 鏈夐偅涔堥偅涔堝鐢滅編鐨勬洸鍎跨瓑鎴戞瓕鍞? So many wild pleasures lay in store for me 鏈夐偅涔堝鑲嗘剰鐨勫揩涔愮瓑鎴戜韩鍙? And so much pain my eyes refused to see 杩樻湁閭d箞澶氱棝鑻?鎴戠殑鍙岀溂鍗磋鑰屼笉瑙? There are so many songs in me that won鈥?/span>t be sung 鎴戞湁澶姝屾洸姘歌繙涓嶄細琚敱璧? I feel the bitter taste of tears upon my tongue 鎴戝皾鍒颁簡鑸屽皷娉按鐨勮嫤娑╂粙鍛? The time has come for me to pay for yesterday 缁堜簬鍒颁簡浠樺嚭浠d环鐨勬椂闂?涓轰簡鏄ㄦ棩 When I was young 褰撴垜骞村皯杞荤媯
鏂囦欢鎿嶄綔
銆€銆€
f = open(鈥?/span>lyrics鈥?/span>) #鎵撳紑鏂囦欢
first_line = f.readline()
print(鈥?/span>first line:鈥?/span>,first_line) #璇讳竴琛?/span>
print(鈥?/span>鎴戞槸鍒嗛殧绾?/span>鈥?/span>.center(50,鈥?/span>-鈥?/span>))
data = f.read()# 璇诲彇鍓╀笅鐨勬墍鏈夊唴瀹?鏂囦欢澶ф椂涓嶈鐢?/span>
print(data) #鎵撳嵃鏂囦欢
f.close() #鍏抽棴鏂囦欢
鎵撳紑鏂囦欢鐨勬ā寮忔湁锛?/p>
- r锛屽彧璇绘ā寮忥紙榛樿锛夈€?/li>
- w锛屽彧鍐欐ā寮忋€傘€愪笉鍙锛涗笉瀛樺湪鍒欏垱寤猴紱瀛樺湪鍒欏垹闄ゅ唴瀹癸紱銆?/li>
- a锛岃拷鍔犳ā寮忋€傘€愬彲璇伙紱 涓嶅瓨鍦ㄥ垯鍒涘缓锛涘瓨鍦ㄥ垯鍙拷鍔犲唴瀹癸紱銆?/li>
"+" 琛ㄧず鍙互鍚屾椂璇诲啓鏌愪釜鏂囦欢
- r+锛屽彲璇诲啓鏂囦欢銆傘€愬彲璇伙紱鍙啓锛涘彲杩藉姞銆?/li>
- w+锛屽啓璇?/li>
- a+锛屽悓a
"U"琛ㄧず鍦ㄨ鍙栨椂锛屽彲浠ュ皢 鑷姩杞崲鎴? 锛堜笌 r 鎴?r+ 妯″紡鍚屼娇鐢級
- rU
- r+U
"b"琛ㄧず澶勭悊浜岃繘鍒舵枃浠讹紙濡傦細FTP鍙戦€佷笂浼營SO闀滃儚鏂囦欢锛宭inux鍙拷鐣ワ紝windows澶勭悊浜岃繘鍒舵枃浠舵椂闇€鏍囨敞锛?/p>
- rb
- wb
- ab
1 def close(self): # real signature unknown; restored from __doc__ 2 """ 3 Close the file. 4 5 A closed file cannot be used for further I/O operations. close() may be 6 called more than once without error. 7 """ 8 pass 9 10 def fileno(self, *args, **kwargs): # real signature unknown 11 """ Return the underlying file descriptor (an integer). """ 12 pass 13 14 def isatty(self, *args, **kwargs): # real signature unknown 15 """ True if the file is connected to a TTY device. """ 16 pass 17 18 def read(self, size=-1): # known case of _io.FileIO.read 19 """ 20 娉ㄦ剰锛屼笉涓€瀹氳兘鍏ㄨ鍥炴潵 21 Read at most size bytes, returned as bytes. 22 23 Only makes one system call, so less data may be returned than requested. 24 In non-blocking mode, returns None if no data is available. 25 Return an empty bytes object at EOF. 26 """ 27 return "" 28 29 def readable(self, *args, **kwargs): # real signature unknown 30 """ True if file was opened in a read mode. """ 31 pass 32 33 def readall(self, *args, **kwargs): # real signature unknown 34 """ 35 Read all data from the file, returned as bytes. 36 37 In non-blocking mode, returns as much as is immediately available, 38 or None if no data is available. Return an empty bytes object at EOF. 39 """ 40 pass 41 42 def readinto(self): # real signature unknown; restored from __doc__ 43 """ Same as RawIOBase.readinto(). """ 44 pass #涓嶈鐢?娌′汉鐭ラ亾瀹冩槸骞插槢鐢ㄧ殑 45 46 def seek(self, *args, **kwargs): # real signature unknown 47 """ 48 Move to new file position and return the file position. 49 50 Argument offset is a byte count. Optional argument whence defaults to 51 SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values 52 are SEEK_CUR or 1 (move relative to current position, positive or negative), 53 and SEEK_END or 2 (move relative to end of file, usually negative, although 54 many platforms allow seeking beyond the end of a file). 55 56 Note that not all file objects are seekable. 57 """ 58 pass 59 60 def seekable(self, *args, **kwargs): # real signature unknown 61 """ True if file supports random-access. """ 62 pass 63 64 def tell(self, *args, **kwargs): # real signature unknown 65 """ 66 Current file position. 67 68 Can raise OSError for non seekable files. 69 """ 70 pass 71 72 def truncate(self, *args, **kwargs): # real signature unknown 73 """ 74 Truncate the file to at most size bytes and return the truncated size. 75 76 Size defaults to the current file position, as returned by tell(). 77 The current file position is changed to the value of size. 78 """ 79 pass 80 81 def writable(self, *args, **kwargs): # real signature unknown 82 """ True if file was opened in a write mode. """ 83 pass 84 85 def write(self, *args, **kwargs): # real signature unknown 86 """ 87 Write bytes b to file, return number written. 88 89 Only makes one system call, so not all of the data may be written. 90 The number of bytes actually written is returned. In non-blocking mode, 91 returns None if the write would block. 92 """ 93 pass
with 璇彞
涓轰簡閬垮厤鎵撳紑鏂囦欢鍚庡繕璁板叧闂紝鍙互閫氳繃绠$悊涓婁笅鏂囷紝鍗筹細
with open(鈥?/span>log鈥?/span>,鈥?/span>r鈥?/span>) as f:
...
濡傛鏂瑰紡锛屽綋with浠g爜鍧楁墽琛屽畬姣曟椂锛屽唴閮ㄤ細鑷姩鍏抽棴骞堕噴鏀炬枃浠惰祫婧愩€?/p>
鍦≒ython 2.7 鍚庯紝with鍙堟敮鎸佸悓鏃跺澶氫釜鏂囦欢鐨勪笂涓嬫枃杩涜绠$悊锛屽嵆
1 with open(鈥?/span>log1鈥?/span>) as obj1, open(鈥?/span>log2鈥?/span>) as obj2: 2 pass
1 1銆佹煡 2 杈撳叆锛歸ww.oldboy.org 3 鑾峰彇褰撳墠backend涓嬬殑鎵€鏈夎褰? 4 5 2銆佹柊寤? 6 杈撳叆锛? 7 arg = { 8 鈥?/span>bakend鈥?/span>: 鈥?/span>www.oldboy.org鈥?/span>, 9 鈥?/span>record鈥?/span>:{ 10 鈥?/span>server鈥?/span>: 鈥?/span>100.1.7.9鈥?/span>, 11 鈥?/span>weight鈥?/span>: 20, 12 鈥?/span>maxconn鈥?/span>: 30 13 } 14 } 15 16 3銆佸垹闄? 17 杈撳叆锛? 18 arg = { 19 鈥?/span>bakend鈥?/span>: 鈥?/span>www.oldboy.org鈥?/span>, 20 鈥?/span>record鈥?/span>:{ 21 鈥?/span>server鈥?/span>: 鈥?/span>100.1.7.9鈥?/span>, 22 鈥?/span>weight鈥?/span>: 20, 23 鈥?/span>maxconn鈥?/span>: 30 24 } 25 } 26 27 闇€姹?/pre>
1 global 2 log 127.0.0.1 local2 3 daemon 4 maxconn 256 5 log 127.0.0.1 local2 info 6 defaults 7 log global 8 mode http 9 timeout connect 5000ms 10 timeout client 50000ms 11 timeout server 50000ms 12 option dontlognull 13 14 listen stats :8888 15 stats enable 16 stats uri /admin 17 stats auth admin:1234 18 19 frontend oldboy.org 20 bind 0.0.0.0:80 21 option httplog 22 option httpclose 23 option forwardfor 24 log global 25 acl www hdr_reg(host) -i www.oldboy.org 26 use_backend www.oldboy.org if www 27 28 backend www.oldboy.org 29 server 100.1.7.9 100.1.7.9 weight 20 maxconn 3000 30 31 鍘熼厤缃枃浠?/pre>
以上是关于python涓栫晫level2的主要内容,如果未能解决你的问题,请参考以下文章
鏀婚槻涓栫晫 reverse Windows_Reverse1