{"id":3135,"date":"2020-03-06T13:58:39","date_gmt":"2020-03-06T05:58:39","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=3135"},"modified":"2020-03-06T13:58:39","modified_gmt":"2020-03-06T05:58:39","slug":"%e3%80%90python%e3%80%91python%e6%a0%b8%e5%bf%83%e7%9f%a5%e8%af%86%e7%82%b9%ef%bc%88%e6%9b%b4%e6%96%b0%e4%b8%ad%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/python\/3135\/","title":{"rendered":"\u3010Python\u3011python\u6838\u5fc3\u77e5\u8bc6\u70b9\uff08\u5168\uff09"},"content":{"rendered":"\n<p><strong>1. \u5217\u51fa 5 \u4e2a\u5e38\u7528 Python \u6807\u51c6\u5e93\uff1f <\/strong><\/p>\n\n\n<p>\u5f88\u591a\uff0cos\u3001time\u3001random\u3001re\u3001math\u3001sys\u7b49<\/p>\n\n\n<p><strong>2. Python \u5185\u5efa\u6570\u636e\u7c7b\u578b\u6709\u54ea\u4e9b\uff1f <\/strong><\/p>\n\n\n<p>str,bytes,int,float,list,dict,tump,set,bool\u7b49\u3002<\/p>\n\n\n<p><strong> 3.\u7b80\u8ff0 with \u65b9\u6cd5\u6253\u5f00\u5904\u7406\u6587\u4ef6\u5e2e\u6211\u4eec\u505a\u4e86\u4ec0\u4e48\uff1f <\/strong><\/p>\n\n\n<p>\u6211\u4eec\u4e00\u822c\u6253\u5f00\u6587\u4ef6\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>file = open('xxx.txt','w')\ntry:\n    file.write('111')\nexcept:\n    pass\nfinally:\n    file.close()<\/code><\/pre>\n\n\n<p>\u800c\u6211\u4eec\u4f7f\u7528with\u5219\u53ef\u4ee5\u76f4\u63a5<\/p>\n\n\n<pre class=\"wp-block-code\"><code>with open('xxx.txt','w') as f:\n    f.write('111')<\/code><\/pre>\n\n\n<p>\u7531with\u5e2e\u6211\u4eec\u6267\u884c\u4e86close\u64cd\u4f5c\uff0c\u4fdd\u8bc1\u4e86\u6587\u4ef6\u7684\u5b89\u5168\u6027\u3002<\/p>\n\n\n<p><strong> 4.\u5217\u51fa Python \u4e2d\u53ef\u53d8\u6570\u636e\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u6570\u636e\u7c7b\u578b\uff0c\u4e3a\u4ec0\u4e48\uff1f <\/strong><\/p>\n\n\n<p><strong>\u53ef\u53d8\u7c7b\u578b<\/strong>\uff1a\u6307\u7684\u662f\u5bf9\u53d8\u91cf\u8fdb\u884cappend\u3001+\u3001-\u7b49\u76f8\u5173\u64cd\u4f5c\u540e\uff0c\u867d\u7136\u6539\u53d8\u4e86\u5bf9\u8c61\u7684\u503c\uff0c\u4f46\u662f\u5bf9\u8c61\u7684id\u4e5f\u5c31\u662f\u5730\u5740\u4e0d\u4f1a\u53d1\u751f\u6539\u53d8\uff0c\u5bf9\u4e8e\u76f8\u540c\u503c\u7684\u53d8\u91cf\uff0c\u5185\u5b58\u4e2d\u6709\u591a\u4efd\u3002\u5305\u62ec\uff1a<\/p>\n\n\n<ul><li>list<\/li><li>dict<\/li><li>set<\/li><li>byte array<\/li><li>user-defined classes\uff08default\uff09<\/li><\/ul>\n\n\n<p><strong>\u4e0d\u53ef\u53d8\u7c7b\u578b<\/strong>\uff1a\u6307\u7684\u662f\u6539\u53d8\u503c\u5c31\u4f1a\u53d8\u6362id\uff0c\u76f8\u540c\u7684\u503c\u5185\u5b58\u4e2d\u53ea\u6709\u4e00\u4efd\uff08\u7c7b\u4f3cjava\u7684<a rel=\"noreferrer noopener\" aria-label=\"\u8fd0\u884c\u65f6\u5e38\u91cf\u6c60\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"http:\/\/www.sniper97.cn\/index.php\/note\/jvm\/1368\/\" target=\"_blank\">\u8fd0\u884c\u65f6\u5e38\u91cf\u6c60<\/a>\uff09\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n<ul><li>int<\/li><li>float<\/li><li>bool<\/li><li>string<\/li><li>tuple<\/li><li>range<\/li><\/ul>\n\n\n<p><strong>5. Python \u83b7\u53d6\u5f53\u524d\u65e5\u671f\uff1f<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><code>from time import localtime.strftime\nprint(strftime('%Y-%m-%d',localtime())<\/code><\/pre>\n\n\n<p><strong>6.\u7edf\u8ba1\u5b57\u7b26\u4e32\u6bcf\u4e2a\u5355\u8bcd\u51fa\u73b0\u7684\u6b21\u6570<\/strong><\/p>\n\n\n<p>\u8fd9\u4e2a\u3002\u3002\u5c31\u662f\u5199\u7a0b\u5e8f\uff0c\u8981\u662f\u975e\u8bf4\u6709\u4e2a\u77e5\u8bc6\u70b9\uff0c\u90a3\u5c31\u662fpython\u7684collections\u5305<\/p>\n\n\n<p> \u8fd9\u4e2a\u6a21\u5757\u5b9e\u73b0\u4e86\u7279\u5b9a\u76ee\u6807\u7684\u5bb9\u5668\uff0c\u4ee5\u63d0\u4f9bPython\u6807\u51c6\u5185\u5efa\u5bb9\u5668  dict , list , set , \u548c tuple \u7684\u66ff\u4ee3\u9009\u62e9\u3002 <\/p>\n\n\n<pre class=\"wp-block-preformatted\">text = 'How are you? I am fine, thank you, and you?'<br \/>text_list = text.split(' ')<br \/>count = Counter(text_list)<br \/>print(count)<\/pre>\n\n\n<p>\u5f97\u5230\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>Counter({'you?': 2, 'How': 1, 'are': 1, 'I': 1, 'am': 1, 'fine,': 1, 'thank': 1, 'you,': 1, 'and': 1})<\/code><\/pre>\n\n\n<p>collections\u4e2d\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u5bb9\u5668\uff08\u6211\u6ca1\u6253\u9519\uff0c\u5c31\u662f\u6709\u5927\u5199\u6709\u5c0f\u5199\uff0c\u6211\u4e5f\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\uff09\uff1a<\/p>\n\n\n<table class=\"wp-block-table\"><tbody><tr><td> namedtuple() <\/td><td> \u521b\u5efa\u547d\u540d\u5143\u7ec4\u5b50\u7c7b\u7684\u5de5\u5382\u51fd\u6570 <\/td><td><\/td><\/tr><tr><td>deque<\/td><td> \u7c7b\u4f3c\u5217\u8868\u7684\u5bb9\u5668\uff0c\u5b9e\u73b0\u4e86\u5728\u4e24\u7aef\u5feb\u901f\u6dfb\u52a0\u548c\u5f39\u51fa<\/td><td><\/td><\/tr><tr><td>ChainMap<\/td><td> \u7c7b\u4f3c\u5b57\u5178\u7684\u5bb9\u5668\u7c7b\uff0c\u5c06\u591a\u4e2a\u6620\u5c04\u96c6\u5408\u5230\u4e00\u4e2a\u89c6\u56fe\u91cc\u9762 <\/td><td><\/td><\/tr><tr><td>Counter<\/td><td> \u5b57\u5178\u7684\u5b50\u7c7b\uff0c\u63d0\u4f9b\u4e86\u53ef\u54c8\u5e0c\u5bf9\u8c61\u7684\u8ba1\u6570\u529f\u80fd <\/td><td><\/td><\/tr><tr><td>OrderedDict<\/td><td> \u5b57\u5178\u5b50\u7c7b\uff0c\u4fdd\u5b58\u4e86\u4ed6\u4eec\u88ab\u6dfb\u52a0\u7684\u987a\u5e8f <\/td><td><\/td><\/tr><tr><td>defaultdict<\/td><td> \u5b57\u5178\u5b50\u7c7b\uff0c\u6709\u4e00\u4e2a\u5de5\u5382\u51fd\u6570\uff0c\u4e3a\u67e5\u8be2\u63d0\u4f9b\u9ed8\u8ba4\u503c<\/td><td><\/td><\/tr><tr><td>UserDict<\/td><td> \u5c01\u88c5\u4e86\u5b57\u5178\u5bf9\u8c61\uff0c\u7b80\u5316\u4e86\u5b57\u5178\u5b50\u7c7b\u5316 <\/td><td><\/td><\/tr><tr><td>UserList<\/td><td> \u5c01\u88c5\u4e86\u5217\u8868\u5bf9\u8c61\uff0c\u7b80\u5316\u4e86\u5217\u8868\u5b50\u7c7b\u5316 <\/td><td><\/td><\/tr><tr><td>UserString<\/td><td> \u5c01\u88c5\u4e86\u5217\u8868\u5bf9\u8c61\uff0c\u7b80\u5316\u4e86\u5b57\u7b26\u4e32\u5b50\u7c7b\u5316 <\/td><td><\/td><\/tr><\/tbody><\/table>\n\n\n<p><strong>namedtuple<\/strong>\u5c31\u76f8\u5f53\u4e8e\u4e00\u4e2a\u53ea\u6709\u5c5e\u6027\u7684\u7c7b\uff0c\u6bd4\u5982\u6211\u4eec\u60f3\u65b0\u5efa\u4e00\u4e2afriend\u7c7b\uff0c\u6709\u51e0\u4e2a\u5c5e\u6027\uff08\u4f46\u662f\u4e0d\u9700\u8981\u65b9\u6cd5\uff09\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"191\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-17.png\" alt=\"\" class=\"wp-image-3138\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-17.png 613w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-17-300x93.png 300w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/><\/figure><\/div>\n\n\n<p>\u5b9a\u4e49\u4e00\u4e2a<strong>deque<\/strong>\u4f46\u540e\u5c31\u53ef\u4ee5\u8c03\u7528append\u3001appendleft\u3001pop\u3001popleft\u3001remove\u7b49\u64cd\u4f5c\u8fdb\u884c\u53cc\u5411\u8fdb\u51fa\u6808\u64cd\u4f5c\u3002<\/p>\n\n\n<p> <strong>ChainMap<\/strong>\uff0c\u5b9e\u8bdd\u5b9e\u8bf4\u6211\u89c9\u5f97\u8fd9\u4e2a\u7528\u5904\u4e0d\u5927\uff0c\u5982\u4e0b\u56fe\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u867d\u7136\u5c06\u591a\u4e2a\u5b57\u5178\u5408\u5e76\u8d77\u6765\u4e86\uff0c\u4f46\u662f\u503c\u80fd\u67e5\u8be2\u5230\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u503c\uff0c\u867d\u7136\u8f6c\u4e86list\u786e\u5b9e\u5c06\u5173\u952e\u5b57\u5408\u5e76\u4e86\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"744\" height=\"234\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-18.png\" alt=\"\" class=\"wp-image-3139\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-18.png 744w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-18-300x94.png 300w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><\/figure><\/div>\n\n\n<p><strong> Counter <\/strong>\u4e0a\u9762\u6f14\u793a\u8fc7\uff0c \u63d0\u4f9b\u4e86\u53ef\u54c8\u5e0c\u5bf9\u8c61\u7684\u8ba1\u6570\u529f\u80fd \u3002<\/p>\n\n\n<p><strong>OrderedDict<\/strong>\uff0c\u4e0d\u505a\u6f14\u793a\uff0c\u4fdd\u5b58\u63d2\u5165\u987a\u5e8f\u3002<\/p>\n\n\n<p><strong>defaultdict<\/strong>\uff0c\u6211\u4e5f\u4e0d\u77e5\u9053\u4e3a\u5565\u4e0a\u9762\u9a7c\u5cf0\u8fd9\u4e2a\u5c31\u8fd9\u6837x\u3002<\/p>\n\n\n<p>\u8fd9\u4e2a\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u8fd4\u56de\uff0c\u6bd4\u5982\u6211\u4eec\u67e5\u627efff\uff0cd\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u7a7a\uff0c\u800cs\u5219\u62a5\u9519\uff0c\u540c\u65f6d\u53ef\u4ee5\u5c06\u76f8\u540c\u7684\u952e\u503c\u5bf9\u8f6c\u5316\u4e3a\u5217\u8868\u3002<\/p>\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"438\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-19.png\" alt=\"\" class=\"wp-image-3140\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-19.png 725w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-19-300x181.png 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/figure>\n\n\n<p>\u5269\u4e0b\u4e09\u4e2aUserxxx\uff0c\u662f\u7528\u6765\u7ed9\u7528\u6237\u81ea\u5b9a\u4e49\u7684\uff08\u6bd4\u5982\u81ea\u5b9a\u4e49\u81ea\u5df1\u7684\u5217\u8868\uff09<\/p>\n\n\n<p><strong>7.\u7528Python\u5220\u9664\u6587\u4ef6\u548c\u7528linux\u547d\u4ee4\u5220\u9664\u6587\u4ef6\u7684\u65b9\u6cd5\uff1a<\/strong><\/p>\n\n\n<p>python\uff1a<\/p>\n\n\n<pre class=\"wp-block-preformatted\">import os<br \/>os.rmdir('path')<br \/>os.remove('file')<\/pre>\n\n\n<p>linux\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>rm file<\/code><\/pre>\n\n\n<p><strong>8.\u5199\u4e00\u6bb5\u81ea\u5b9a\u4e49\u5f02\u5e38\u4ee3\u7801<\/strong><\/p>\n\n\n<pre class=\"wp-block-preformatted\">class MyError(Exception):<br \/>    pass<\/pre>\n\n\n<p><strong>9.\u4e3e\u4f8b\u8bf4\u660e\u5f02\u5e38\u6a21\u5757\u4e2d try except else finally\u7684\u76f8\u5173\u610f\u4e49<\/strong><\/p>\n\n\n<pre class=\"wp-block-preformatted\">def divide(x, y):<br \/>    try:<br \/>        result = x \/ y<br \/>    except ZeroDivisionError:<br \/>        print(\"division by zero!\")<br \/>    else:<br \/>        print(\"result\" + result)<br \/>    finally:<br \/>        print(\"exit\")<\/pre>\n\n\n<p>try\u4e2d\u5199\u9700\u8981\u4fdd\u62a4\u7684\u4ee3\u7801\uff0cexcept\u5199\u5f02\u5e38\u7684\u5904\u7406\uff0celse\u4e2d\u5199try\u4e2d\u4e0d\u5f15\u53d1\u5f02\u5e38\u540e\u5fc5\u987b\u6267\u884c\u7684\u4ee3\u7801\uff0cfinally\u5219\u662f\u5728\u4efb\u4f55\u60c5\u51b5\u4e0b\u90fd\u4f1a\u88ab\u6267\u884c\u7684\u4ee3\u7801\u3002<\/p>\n\n\n<p><strong>10.\u9047\u5230bug\u5982\u4f55\u5904\u7406\uff1f<\/strong><\/p>\n\n\n<p>\u8fd9\u4e2a\u6709\u70b9\u4ec1\u8005\u89c1\u4ec1\u4e86\uff0c\u9996\u5148\u4e00\u5b9a\u662f\u770b\u62a5\u9519\uff0c\u770b\u62a5\u9519\u6808\u6700\u9876\u5c42\u662f\u54ea\u91cc\u7684\u4ee3\u7801\uff0c\u4e00\u822c\u6211\u4f1a\u5b9a\u4f4d\u5230\u62a5\u9519\u6808\u91cc\u6700\u5148\u51fa\u73b0\u6211\u7684\u4ee3\u7801\u7684\u90e8\u5206\uff0c\u7136\u540e\u89c2\u5bdf\u62a5\u9519\u4fe1\u606f\uff0c\u5206\u6790\u60c5\u51b5\u3002<\/p>\n\n\n<p>\u5982\u679c\u5206\u6790\u4e0d\u51fa\u6765\u6216\u8005\u8f83\u96be\u5206\u6790\uff0c\u9700\u8981\u4e00\u6b65\u4e00\u6b65debug\u3001\u6dfb\u52a0\u4e2d\u95f4\u72b6\u6001\u53d8\u91cf\u554a\u6216\u8005\u6574\u7406\u601d\u8def\uff0c\u53cd\u6b63\u624b\u6bb5\u4e0d\u5c11\uff0c\u5177\u4f53\u53ef\u80fd\u8981\u770b\u60c5\u51b5\u3002<\/p>\n\n\n<p><strong>11.\u8c08\u8c08Python\u548c\u5176\u4ed6\u8bed\u8a00\u7684\u533a\u522b<\/strong><\/p>\n\n\n<p>python\u5bf9\u4e8e\u5176\u4ed6\u6240\u6709\u8bed\u8a00\u90fd\u4e0d\u5177\u5907\u7684\u4e00\u4e2a\u4f18\u70b9\u5c31\u662f\u7b2c\u4e09\u65b9\u5e93\u592a\u5f3a\u5927\u4e86\uff0c\u751a\u81f3\u6211\u4eec\u5370\u8c61\u4e2d\u7684\u5199windows\u9a71\u52a8\u8fd9\u79cd\u5fc5\u987b\u7528C++\u89e3\u51b3\u7684\u6d3b\u90fd\u53ef\u4ee5\u7528python\u6765\u89e3\u51b3\u3002<\/p>\n\n\n<p>\u4f46\u662f\u7f3a\u70b9\u4e5f\u5f88\u660e\u663e\uff0c\u5c31\u662f\u6162\u548c\u81c3\u80bf\uff08\u4e0d\u662f\u4ee3\u7801\u884c\u4e0a\u7684\uff09\uff0c\u6162\u8bf4\u7684\u5c31\u662f\u76f8\u5bf9java\u548cc++\u7684\u8fd0\u884c\u901f\u5ea6\u6765\u8bf4\uff0c\u786e\u5b9e\u8fd8\u662f\u6162\uff0cjava\u7ecf\u8fc7\u4f18\u5316\u5df2\u7ecf\u548cc++\u4e0d\u4f1a\u5dee\u5f88\u591a\u3002\u518d\u4e00\u4e2a\u662f\u81c3\u80bf\uff0c\u867d\u7136python\u53ef\u4ee5\u7528\u51e0\u884c\u89e3\u51b3\u522b\u7684\u8bed\u8a00\u5f88\u591a\u884c\u89e3\u51b3\u7684\u4e8b\u60c5\uff0c\u4f46\u662f\u5728\u6253\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u65f6\u5019\uff0cpython\u7684\u6587\u4ef6\u4f1a\u660e\u663e\u6bd4\u5176\u4ed6\u8bed\u8a00\u5927\uff08\u6211\u4e5f\u4e0d\u77e5\u9053\u662f\u6211\u7684\u6253\u5305\u5e93\u6709\u95ee\u9898\u8fd8\u662f\u786e\u5b9e\u8fd9\u6837\uff09\u3002<\/p>\n\n\n<p><strong>12.\u7b80\u8ff0\u89e3\u91ca\u578b\u548c\u7f16\u8bd1\u578b\u8bed\u8a00<\/strong><\/p>\n\n\n<p>\u89e3\u91ca\u578b\u8bed\u8a00\u8fb9\u8fd0\u884c\u53d8\u89e3\u91ca\uff0c\u4e5f\u5c31\u662f\u5982\u679c\u4f60\u5728\u67d0\u4e00\u6b65\u51fa\u73b0\u4e00\u4e9b\u9519\u8bef\uff08\u6bd4\u5982\u572812\u884c\u4f60\u8fdb\u884c\u4e86\u4e00\u4e2a\u96640\u64cd\u4f5c\uff09\uff0c\u5728\u7a0b\u5e8f\u8fd0\u884c\u5230\u8fd9\u4e00\u884c\u4e4b\u524d\u5e76\u4e0d\u4f1a\u629b\u51fa\u4efb\u4f55\u9519\u8bef\uff0c\u56e0\u4e3a\u4ed6\u8fd8\u6ca1\u770b\u5230\u8fd9\u3002<\/p>\n\n\n<p>\u7f16\u8bd1\u578b\u8bed\u8a00\u5148\u8fdb\u884c\u7f16\u8bd1\uff0c\u4e5f\u5c31\u662f\u4f1a\u5c3d\u53ef\u80fd\u4fdd\u8bc1\u7a0b\u5e8f\u7684\u53ef\u8fd0\u884c\uff0c\u5f80\u5f80\u76f4\u63a5\u8fdb\u884c\u96640\u64cd\u4f5c\u7684\u4ee3\u7801\u662f\u7f16\u8bd1\u4e0d\u901a\u7684\u3002<\/p>\n\n\n<p>\u987a\u4fbf\u4e00\u8bf4\uff0cjava\u73b0\u5728\u5df2\u7ecf\u4e0d\u518d\u662f\u7eaf\u7cb9\u7684\u89e3\u91ca\u578b\u8bed\u8a00\u4e86\uff0c\u867d\u7136\u90fd\u8fd9\u4e48\u8bf4\uff0c\u4f46\u662f\u7ecf\u8fc7\u51e0\u6b21JVM\u7684\u66f4\u65b0\u8fed\u4ee3\uff0c\u73b0\u5728\u5df2\u7ecf\u5c5e\u4e8e\u89e3\u91ca\u578b\u548c\u7f16\u8bd1\u578b\u5171\u6709\u7684\u8bed\u8a00\u4e86\uff0cJVM\u4f1a\u6311\u9009\u4e00\u90e8\u5206\u5e38\u7528\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1\u3002<\/p>\n\n\n<p><strong>13.Python\u7684\u89e3\u91ca\u5668\u79cd\u7c7b\u4ee5\u53ca\u76f8\u5173\u7279\u70b9<\/strong><\/p>\n\n\n<p>\u7531\u4e8e\u6211\u4eec\u7f16\u5199\u7684\u662f.py\uff0c\u9700\u8981\u89e3\u91ca\u5668\u53bb\u6267\u884cpy\u6587\u4ef6\uff0c\u800c\u4e14\u7531\u4e8epython\u662f\u4e00\u95e8\u5f00\u6e90\u8bed\u8a00\uff0c\u89e3\u91ca\u5668\u7406\u8bba\u4e0a\u53ef\u4ee5\u7531\u4efb\u4f55\u4eba\u7f16\u5199\uff0c\u56e0\u6b64\u786e\u5b9e\u5b58\u5728\u4e0d\u5c11\u89e3\u91ca\u5668\u3002<\/p>\n\n\n<p>\u6211\u77e5\u9053\u89e3\u91ca\u5668\uff0c\u4f46\u662f\u4e0d\u77e5\u9053\u8fd8\u6709\u597d\u591a\u54c8\u54c8\u54c8\u54c8\uff0c\u8fd9\u4e2a\u6211\u8fd8\u771f\u4e0d\u77e5\u9053\uff0c\u5b66\u4e60\u4e86\u3002<\/p>\n\n\n<ul><li>CPython\uff1a\u8fd9\u4e2a\u5c31\u662f\u6211\u4eec\u65e5\u5e38\u4f7f\u7528\u7684python\u89e3\u91ca\u5668\uff0c\u7531\u4e8e\u662f\u4f7f\u7528C\u8bed\u8a00\u8fdb\u884c\u7f16\u5199\u7684\uff0c\u56e0\u6b64\u53c8\u53eb\u505aCPython\u3002<\/li><li>IPython\uff1a\u57fa\u4e8eCPython\u4e4b\u4e0a\u7684\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u8fd9\u4e48\u4e00\u8bf4\u6211\u4e5f\u77e5\u9053\u4e86\uff0cjupyter\u90a3\u4e2a\u4e1c\u897f\uff0c\u4e4b\u524d\u5c31\u53ebipython notebook\uff0c\u540e\u6765\u6539\u6210\u4e86jupyter notebook\uff0c\u5c31\u662f\u4e00\u4e2a\u5728\u53ef\u89c6\u5316\u4e0a\u89e3\u6790\u4ee3\u7801\u7684\u4e1c\u897f\u3002<\/li><li>PyPy\uff1a\u4ed6\u7684\u76ee\u6807\u662f\u6267\u884c\u901f\u5ea6\u3002\u91c7\u7528JIT\u6280\u672f\uff08\u8fd9\u4e5f\u662fJVM\u4ee3\u7801\u4f18\u5316\u7684\u6280\u672f\uff09\uff0c\u5bf9py\u4ee3\u7801\u91c7\u7528\u52a8\u6001\u7f16\u8bd1\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cPyPy\u4e0eCpython\u7684\u4ee3\u7801\u6709\u4e00\u4e22\u4e22\u4e0d\u540c\u3002<\/li><li>Jython\uff1a\u8fd0\u884c\u5728JVM\u4e0a\u7684python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u76f4\u63a5\u628aPython\u4ee3\u7801\u7f16\u8bd1\u6210Java\u5b57\u8282\u7801\u6587\u4ef6\u3002<\/li><li>IronPython\uff1a\u548cJyhon\u7c7b\u4f3c\uff0c\u7f16\u8bd1\u6210.Net\u3002<\/li><\/ul>\n\n\n<p><strong>14.\u8bf4\u8bf4\u4f60\u77e5\u9053\u7684Python3\u548cPython2\u7684\u533a\u522b<\/strong><\/p>\n\n\n<p>\u6027\u80fd\uff1a<\/p>\n\n\n<p>\u65e9\u8d77\u7684python3\u7248\u672c\u901f\u5ea6\u6bd4python2\u6162\u5f88\u591a\u3002<\/p>\n\n\n<p>\u7f16\u7801\uff1a<\/p>\n\n\n<p>python2\u7684\u9ed8\u8ba4\u7f16\u7801\u4e3aASCII\uff0c\u800cpython3\u7684\u4e3autf-8<\/p>\n\n\n<p>\u8bed\u6cd5\uff1a<\/p>\n\n\n<ul><li>\u52a0\u5165\u4e86as\u548cwith\uff0cTrue\uff0cFalse\u548cNone<\/li><li>\u9664\u6cd5\u8fd4\u56de\u6d6e\u70b9\u6570\uff0c\/\/\u6574\u9664<\/li><li>print\u8bed\u53e5\u6539\u4e3aprint()\u51fd\u6570<\/li><li>raw_input\u6539\u4e3ainput<\/li><\/ul>\n\n\n<p><strong>15.Python3\u548cPython2\u4e2d\u7684int\u548clong\u7684\u533a\u522b\uff1a<\/strong><\/p>\n\n\n<p>python2\u4e2d\u6709long\uff0cpython3\u4e2d\u6ca1\u6709long\uff0c\u4f46\u662fint\u529f\u80fd\u4e0a\u548cpython2\u7684long\u5f88\u50cf\u3002<\/p>\n\n\n<p><strong>16.xrange\u548crange\u7684\u533a\u522b<\/strong><\/p>\n\n\n<p>python2\u4e2d\u7684xrange\u7b49\u540c\u4e8epython3\u7684range\uff0c\u540c\u65f6python3\u4e2d\u5e76\u6ca1\u6709xrange\u3002<\/p>\n\n\n<p><strong>17.\u4ec0\u4e48\u662fPEP8\uff1f<\/strong><\/p>\n\n\n<p>\u300aPython Enhancement Proposal #8\u300b\uff0c8\u53f7python\u589e\u5f3a\u63d0\u6848\uff0c\u662f\u4e00\u4e2a\u9488\u5bf9Python\u4ee3\u7801\u683c\u5f0f\u8fdb\u884c\u89c4\u8303\u7684\u4e00\u4e2a\u6587\u6863\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n<ul><li>\u9996\u884c\u7f29\u8fdb4\u4e2a\u7a7a\u683c\uff0c\u4e0d\u80fd\u4f7f\u7528tab<\/li><li>\u6bcf\u884c\u6700\u5927\u7a0b\u5ea679<\/li><li>\u7c7b\u548ctop-level\u65b9\u6cd5\u5b9a\u4e49\u7a7a\u4e24\u884c\uff0c\u7c7b\u4e2d\u65b9\u6cd5\u5b9a\u4e49\u7a7a\u4e00\u884c\uff0c\u51fd\u6570\u5185\u903b\u8f91\u65e0\u5173\u6bb5\u843d\u7a7a\u4e00\u884c\uff0c\u5176\u4ed6\u5730\u65b9\u5c3d\u91cf\u4e0d\u8981\u7a7a\u884c<\/li><li>\u6a21\u5757\u7684\u5bfc\u5165\u987a\u5e8f\uff1a\u6807\u51c6\u5e93\uff0c\u4e09\u65b9\u5e93\uff0c\u81ea\u5b9a\u4e49\u5e93\uff0c\u4e4b\u95f4\u7a7a\u4e00\u884c\u3002<\/li><li>\u4e0d\u63a8\u8350\u4e00\u4e2aimport\u591a\u4e2a\u5e93\uff08import os,time\uff09<\/li><li>\u6ce8\u91ca\u548c\u547d\u540d\u89c4\u8303<\/li><li>\u5c3d\u91cf\u4f7f\u7528is is not \u53d6\u4ee3==\uff0cif x is not None \u4f18\u4e8eif x<\/li><li>\u6bcf\u4e2a\u6a21\u5757\u90fd\u8981\u6709\u81ea\u5df1\u7684\u5f02\u5e38\u7c7b<\/li><li>try\u4e2d\u7684\u4ee3\u7801\u5c3d\u91cf\u5c11<\/li><\/ul>\n\n\n<p><strong>18.\u4e86\u89e3Python\u4e4b\u7985\u5417\uff1f<\/strong><\/p>\n\n\n<p>Python\u793e\u533a\u7684\u5386\u5e74\u90fd\u5305\u542b\u5728Tim Peters\u64b0\u5199\u7684Python\u4e4b\u7985\u4e2d\uff0c \u8981\u83b7\u6089\u8fd9\u4e9b\u6709\u5173\u7f16\u5199\u4f18\u79c0Python\u4ee3\u7801\u7684\u6307\u5bfc\u539f\u5219\uff0c\u53ea\u9700\u5728\u89e3\u91ca\u5668\u4e2d\u6267\u884c\u547d\u4ee4import this <\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"569\" height=\"363\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-29.png\" alt=\"\" class=\"wp-image-3158\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-29.png 569w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-29-300x191.png 300w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/figure><\/div>\n\n\n<ul><li>\u4f18\u7f8e\u80dc\u4e8e\u4e11\u964b\uff08Python \u4ee5\u7f16\u5199\u4f18\u7f8e\u7684\u4ee3\u7801\u4e3a\u76ee\u6807\uff09<\/li><li> \u660e\u4e86\u80dc\u4e8e\u6666\u6da9\uff08\u4f18\u7f8e\u7684\u4ee3\u7801\u5e94\u5f53\u662f\u660e\u4e86\u7684\uff0c\u547d\u540d\u89c4\u8303\uff0c\u98ce\u683c\u76f8\u4f3c\uff09<\/li><li> \u7b80\u6d01\u80dc\u4e8e\u590d\u6742\uff08\u4f18\u7f8e\u7684\u4ee3\u7801\u5e94\u5f53\u662f\u7b80\u6d01\u7684\uff0c\u4e0d\u8981\u6709\u590d\u6742\u7684\u5185\u90e8\u5b9e\u73b0\uff09<\/li><li> \u590d\u6742\u80dc\u4e8e\u51cc\u4e71\uff08\u5982\u679c\u590d\u6742\u4e0d\u53ef\u907f\u514d\uff0c\u90a3\u4ee3\u7801\u95f4\u4e5f\u4e0d\u80fd\u6709\u96be\u61c2\u7684\u5173\u7cfb\uff0c\u8981\u4fdd\u6301\u63a5\u53e3\u7b80\u6d01\uff09<\/li><li> \u6241\u5e73\u80dc\u4e8e\u5d4c\u5957\uff08\u4f18\u7f8e\u7684\u4ee3\u7801\u5e94\u5f53\u662f\u6241\u5e73\u7684\uff0c\u4e0d\u80fd\u6709\u592a\u591a\u7684\u5d4c\u5957\uff09<\/li><li> \u95f4\u9694\u80dc\u4e8e\u7d27\u51d1\uff08\u4f18\u7f8e\u7684\u4ee3\u7801\u6709\u9002\u5f53\u7684\u95f4\u9694\uff0c\u4e0d\u8981\u5962\u671b\u4e00\u884c\u4ee3\u7801\u89e3\u51b3\u95ee\u9898\uff09<\/li><li> \u53ef\u8bfb\u6027\u5f88\u91cd\u8981\uff08\u4f18\u7f8e\u7684\u4ee3\u7801\u662f\u53ef\u8bfb\u7684\uff09<\/li><li> \u5373\u4fbf\u5047\u501f\u7279\u4f8b\u7684\u5b9e\u7528\u6027\u4e4b\u540d\uff0c\u4e5f\u4e0d\u53ef\u8fdd\u80cc\u8fd9\u4e9b\u89c4\u5219\uff08\u8fd9\u4e9b\u89c4\u5219\u81f3\u9ad8\u65e0\u4e0a\uff09<\/li><li>\u5f53\u5b58\u5728\u591a\u79cd\u53ef\u80fd\uff0c\u4e0d\u8981\u5c1d\u8bd5\u53bb\u731c\u6d4b<\/li><li> \u800c\u662f\u5c3d\u91cf\u627e\u4e00\u79cd\uff0c\u6700\u597d\u662f\u552f\u4e00\u4e00\u79cd\u660e\u663e\u7684\u89e3\u51b3\u65b9\u6848\uff08\u5982\u679c\u4e0d\u786e\u5b9a\uff0c\u5c31\u7528\u7a77\u4e3e\u6cd5\uff09<\/li><li> \u867d\u7136\u8fd9\u5e76\u4e0d\u5bb9\u6613\uff0c\u56e0\u4e3a\u4f60\u4e0d\u662f Python \u4e4b\u7236\uff08\u8fd9\u91cc\u7684 Dutch \u662f\u6307 Guido \uff09<\/li><li>\u505a\u4e5f\u8bb8\u597d\u8fc7\u4e0d\u505a\uff0c\u4f46\u4e0d\u5047\u601d\u7d22\u5c31\u52a8\u624b\u8fd8\u4e0d\u5982\u4e0d\u505a\uff08\u52a8\u624b\u4e4b\u524d\u8981\u7ec6\u601d\u91cf\uff09<\/li><li>\u547d\u540d\u7a7a\u95f4\u662f\u4e00\u79cd\u7edd\u5999\u7684\u7406\u5ff5\uff0c\u6211\u4eec\u5e94\u5f53\u591a\u52a0\u5229\u7528\uff08\u5021\u5bfc\u4e0e\u53f7\u53ec\uff09<\/li><\/ul>\n\n\n<p><strong>19. \u4e86\u89e3 docstring \u4e48\uff1f <\/strong><\/p>\n\n\n<p>\u4e0b\u56fe\u5c31\u662f\u4e00\u4e2adocstring\uff0c\u4f7f\u7528\u4e09\u5bf9\u53cc\u5f15\u53f7\uff08\u6216\u8005\u5355\u5f15\u53f7\uff09\u6765\u58f0\u660e\uff0c\u901a\u8fc7\u65b9\u6cd5\u540d.__doc__\u6765\u663e\u793a\uff08partition.__doc__\uff09<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"148\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-30.png\" alt=\"\" class=\"wp-image-3159\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-30.png 381w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-30-300x117.png 300w\" sizes=\"(max-width: 381px) 100vw, 381px\" \/><\/figure><\/div>\n\n\n<p><strong> 20.\u4e86\u89e3\u7c7b\u578b\u6ce8\u89e3\u4e48\uff1f <\/strong><\/p>\n\n\n<p>\u5982\u4e0b\uff0c\u5206\u522b\u5bf9x\uff0cy\u548c\u8fd4\u56de\u503c\u8fdb\u884c\u4e86\u5b9a\u4e49\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>def add(x:int, y:int) -> int:<\/code><\/pre>\n\n\n<p><strong>21. \u4f8b\u4e3e\u4f60\u77e5\u9053 Python \u5bf9\u8c61\u7684\u547d\u540d\u89c4\u8303\uff0c\u4f8b\u5982\u65b9\u6cd5\u6216\u8005\u7c7b\u7b49 <\/strong><\/p>\n\n\n<ul><li>\u7c7b\uff1a\u9996\u5b57\u6bcd\u5927\u5c0f\uff0c\u9a7c\u5cf0\u547d\u540d\u6cd5<\/li><li>\u53d8\u91cf\uff1a\u5c0f\u5199\uff0c\u4e0b\u5212\u7ebf\u547d\u540d\u6cd5<\/li><li>\u5e38\u91cf\uff1a\u5168\u90e8\u5927\u5199<\/li><\/ul>\n\n\n<p><strong>22. Python \u4e2d\u7684\u6ce8\u91ca\u6709\u51e0\u79cd\uff1f <\/strong><\/p>\n\n\n<p>\u4e24\u79cd\uff0c\u5206\u522b\u662f\u5355\u884c\u6ce8\u91ca#\u548c\u591a\u884c\u6ce8\u91ca&#8221;&#8221;&#8221;\u8fd9\u662f\u591a\u884c\u6ce8\u91ca&#8221;&#8221;&#8221;\u3002<\/p>\n\n\n<p><strong>23.\u5982\u4f55\u4f18\u96c5\u7684\u7ed9\u4e00\u4e2a\u51fd\u6570\u52a0\u6ce8\u91ca<\/strong><\/p>\n\n\n<p>\u6253\u5b8c\u65b9\u6cd5\u7684\u5192\u53f7\u540e\u56de\u8f66\uff0c\u6309\u4ee8\u5f15\u53f7\u56de\u8f66\uff0c\u6253\u6587\u6863\u6ce8\u91ca\u3002<\/p>\n\n\n<p><strong>24.\u5982\u4f55\u7ed9\u53d8\u91cf\u52a0\u6ce8\u91ca<\/strong><\/p>\n\n\n<p>\u4e00\u822c\u662f\u4ee3\u7801\u540e\u7a7a2\u683c<\/p>\n\n\n<pre class=\"wp-block-code\"><code>a = 3  # \u8fd9\u662f\u53d8\u91cfa<\/code><\/pre>\n\n\n<p>\u4f46\u662f\u6211\u611f\u89c9\u8fd9\u597d\u4e71\u554a\u54c8\u54c8\u54c8\u8fd8\u662f\u559c\u6b22\u5728\u4e0a\u9762\u53e6\u8d77\u4e00\u884c\u6ce8\u91ca<\/p>\n\n\n<p><strong>25.Python\u4ee3\u7801\u7f29\u8fdb\u4e2d\u662f\u5426\u652f\u6301Tab\u952e\u548c\u7a7a\u683c\u6df7\u7528<\/strong><\/p>\n\n\n<p>\u4e0d\u652f\u6301\uff0c\u5f88\u591a\u7f16\u8bd1\u5668\u5b9e\u9645\u4e0a\u662f\u5c06tab\u8f6c\u6362\u4e3an\u4e2a\u7a7a\u683c\uff08\u53ef\u8bbe\u7f6e\uff09\u3002<\/p>\n\n\n<p><strong>26.\u662f\u5426\u53ef\u4ee5\u5728\u4e00\u53e5import\u4e2d\u5bfc\u5165\u591a\u4e2a\u5e93\uff1f<\/strong><\/p>\n\n\n<p>\u53ef\u4ee5\uff0c\u4f46\u4e0d\u63a8\u8350\uff08PEP8\u6807\u51c6\u4e2d \u63d0\u8fc7\uff09<\/p>\n\n\n<p><strong>27.\u5728\u7ed9py\u6587\u4ef6\u547d\u540d\u7684\u65f6\u5019\u5e94\u8be5\u6ce8\u610f\u4ec0\u4e48\uff1f<\/strong><\/p>\n\n\n<ul><li>\u907f\u514dpython\u7684\u4fdd\u7559\u5b57\u3001\u5173\u952e\u5b57<\/li><li>\u907f\u514d\u5e38\u7528\u7b2c\u4e09\u65b9\u5e93\u7684\u5173\u952e\u5b57\u3001\u4fdd\u7559\u5b57<\/li><li>\u53ea\u80fd\u4f7f\u7528\u6570\u5b57\u3001\u5b57\u6bcd\u548c\u4e0b\u5212\u7ebf\u3002<\/li><li>\u53ea\u80fd\u4ee5\u5b57\u6bcd\u548c\u4e0b\u5212\u7ebf\u5f00\u5934\u3002<\/li><\/ul>\n\n\n<p><strong>28.\u4e3e\u51e0\u4e2apython\u4ee3\u7801\u98ce\u683c\u5de5\u5177\uff1a<\/strong><\/p>\n\n\n<p>Pylint\u3001Black\u7b49\uff0c\u4e3b\u8981\u529f\u80fd\u7c7b\u4f3c\u4e8ejava\u7684\u90a3\u4e2aalibaba\u89c4\u8303\u811a\u672c\uff0c\u68c0\u67e5\u5b9a\u4e49\u7b26\u4e0d\u7b26\u5408\u89c4\u8303\u3001\u5b9a\u4e49\u7684\u63a5\u53e3\u662f\u5426\u90fd\u88ab\u4f7f\u7528\u7b49\uff0c\u5728\u5b89\u88c5\u4e4b\u540e\u53f3\u952e\u53c8\u4e00\u4e2acheck\u5373\u53ef\u68c0\u67e5\u9519\u8bef\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"798\" height=\"362\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-43.png\" alt=\"\" class=\"wp-image-3178\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-43.png 798w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-43-300x136.png 300w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-43-768x348.png 768w\" sizes=\"(max-width: 798px) 100vw, 798px\" \/><\/figure><\/div>\n\n\n<p><strong>29.\u5217\u4e3ePython\u4e2d\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff1a<\/strong><\/p>\n\n\n<p>\u518d\u653e\u9001\uff1f\u8fd9\u548c\u7b2c\u4e8c\u9898\u6709\u5565\u533a\u522b<\/p>\n\n\n<p><strong>30.\u5982\u4f55\u533a\u522b\u53ef\u53d8\u6570\u636e\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u6570\u636e\u7c7b\u578b\uff1a<\/strong><\/p>\n\n\n<p>\u53c8\u662f\u518d\u653e\u9001<\/p>\n\n\n<p><strong>31.\u5982\u4f55\u5c06\u2018hello world\u2019\u8f6c\u6362\u4e3a\u9996\u5b57\u6bcd\u5927\u5199\u2018Hello World\u2019<\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"232\" height=\"98\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-44.png\" alt=\"\" class=\"wp-image-3179\"\/><\/figure><\/div>\n\n\n<p>\u53e6\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"206\" height=\"87\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-45.png\" alt=\"\" class=\"wp-image-3180\"\/><\/figure><\/div>\n\n\n<p><strong>32.\u5982\u4f55\u68c0\u6d4b\u5b57\u7b26\u4e32\u4e2d\u53ea\u542b\u6570\u5b57\uff1f<\/strong><\/p>\n\n\n<p>\u8fd9\u53e5\u8bdd\u5176\u5b9e\u770b\u600e\u4e48\u5b9a\u4e49\u2018\u6570\u5b57\u2019\uff0c\u79d1\u5b66\u6280\u672f\u6cd5\u6216\u8005+5\uff0c-5\u7b97\u6570\u5b57\u5417\uff1f\u5982\u679c\u90fd\u4e0d\u7b97\uff0c\u90a3\u4e48\u4e0b\u9762\u8fd9\u6837\u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"187\" height=\"136\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-47.png\" alt=\"\" class=\"wp-image-3184\"\/><\/figure><\/div>\n\n\n<p>\u5982\u679c\u7b97\uff0c\u9700\u8981\u505a\u7684\u5c31\u662f\u8fd9\u6837\uff1a<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"248\" height=\"150\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-48.png\" alt=\"\" class=\"wp-image-3185\"\/><\/figure><\/div>\n\n\n<p><strong>33. \u5c06\u5b57\u7b26\u4e32&#8221;ilovechina&#8221;\u8fdb\u884c\u53cd\u8f6c <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"177\" height=\"86\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-49.png\" alt=\"\" class=\"wp-image-3186\"\/><\/figure><\/div>\n\n\n<p><strong>34. Python \u4e2d\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u5f0f\u4f60\u77e5\u9053\u54ea\u4e9b\uff1f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"317\" height=\"191\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-74.png\" alt=\"\" class=\"wp-image-3217\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-74.png 317w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-74-300x181.png 300w\" sizes=\"(max-width: 317px) 100vw, 317px\" \/><\/figure><\/div>\n\n\n<p><strong>35. \u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\u5f00\u5934\u548c\u672b\u5c3e\u90fd\u6709\u7a7a\u683c\uff0c\u6bd4\u5982\u201c adabdw \u201d,\u8981\u6c42\u5199\u4e00\u4e2a\u51fd\u6570\u628a\u8fd9\u4e2a\u5b57\u7b26\u4e32\u7684\u524d\u540e\u7a7a\u683c\u90fd\u53bb\u6389\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"243\" height=\"141\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-75.png\" alt=\"\" class=\"wp-image-3218\"\/><\/figure><\/div>\n\n\n<p><strong>36. \u83b7\u53d6\u5b57\u7b26\u4e32\u201d123456\u201c\u6700\u540e\u7684\u4e24\u4e2a\u5b57\u7b26\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"154\" height=\"82\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-76.png\" alt=\"\" class=\"wp-image-3219\"\/><\/figure><\/div>\n\n\n<p><strong>37. \u4e00\u4e2a\u7f16\u7801\u4e3a GBK \u7684\u5b57\u7b26\u4e32 S\uff0c\u8981\u5c06\u5176\u8f6c\u6210 UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\uff0c\u5e94\u5982\u4f55\u64cd\u4f5c\uff1f <\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><code>s.decode(\"gbk\").encode(\"utf-8\")<\/code><\/pre>\n\n\n<p><strong>38.s=&#8221;info\uff1axiaoZhang 33 shandong&#8221;\uff0c\u7528\u6b63\u5219\u5207\u5206\u5b57\u7b26\u4e32\u8f93\u51fa&#8217;info&#8217;, &#8216;xiaoZhang&#8217;, &#8217;33&#8217;, &#8216;shandong&#8217;       a = &#8220;\u4f60\u597d \u4e2d\u56fd &#8220;\uff0c\u53bb\u9664\u591a\u4f59\u7a7a\u683c\u53ea\u7559\u4e00\u4e2a\u7a7a\u683c\u3002<\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"157\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-81.png\" alt=\"\" class=\"wp-image-3224\"\/><\/figure><\/div>\n\n\n<p><strong>39.(1)\u600e\u6837\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199 (2)\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7\u3001\u4e09\u5f15\u53f7\u7684\u533a\u522b\uff1f <\/strong><\/p>\n\n\n<pre class=\"wp-block-preformatted\">s = 'HAHAHA'<br \/>print(s.lower())<\/pre>\n\n\n<p>\u5355\u5f15\u53f7\u53cc\u5f15\u53f7\u6ca1\u6709\u533a\u522b\uff0c\u4f46\u662f\u6709\u4e00\u70b9\uff0c\u5c31\u662f\u5355\u5f15\u53f7\u4e2d\u53cc\u5f15\u53f7\u53ef\u4ee5\uff0c\u4f46\u662f\u518d\u4f7f\u7528\u5355\u5f15\u53f7\u9700\u8981\u8f6c\u4e49\uff0c\u53cc\u5f15\u53f7\u540c\u7406\u3002\u4e09\u5f15\u53f7\u662fdocstring\u548c\u591a\u884c\u6ce8\u91ca\u3002<\/p>\n\n\n<p><strong>40. \u5df2\u77e5 AList = [1,2,3,1,2],\u5bf9 AList \u5217\u8868\u5143\u7d20\u53bb\u91cd\uff0c\u5199\u51fa\u5177\u4f53\u8fc7\u7a0b\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"223\" height=\"84\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-78.png\" alt=\"\" class=\"wp-image-3221\"\/><\/figure><\/div>\n\n\n<p><strong>41. \u5982\u4f55\u5b9e\u73b0 &#8220;1,2,3&#8221; \u53d8\u6210 [&#8220;1&#8243;,&#8221;2&#8243;,&#8221;3&#8221;] <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"197\" height=\"80\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-79.png\" alt=\"\" class=\"wp-image-3222\"\/><\/figure><\/div>\n\n\n<p><strong>42. \u7ed9\u5b9a\u4e24\u4e2a list\uff0cA \u548c B\uff0c\u627e\u51fa\u76f8\u540c\u5143\u7d20\u548c\u4e0d\u540c\u5143\u7d20 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"244\" height=\"205\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-80.png\" alt=\"\" class=\"wp-image-3223\"\/><\/figure><\/div>\n\n\n<p><strong>43. [[1,2],[3,4],[5,6]]\u4e00\u884c\u4ee3\u7801\u5c55\u5f00\u8be5\u5217\u8868\uff0c\u5f97\u51fa[1,2,3,4,5,6] <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"83\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-82.png\" alt=\"\" class=\"wp-image-3225\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-82.png 306w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-82-300x81.png 300w\" sizes=\"(max-width: 306px) 100vw, 306px\" \/><\/figure><\/div>\n\n\n<p><strong> 44.\u5408\u5e76\u5217\u8868[1,5,7,9]\u548c[2,2,6,8] <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"196\" height=\"120\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-83.png\" alt=\"\" class=\"wp-image-3226\"\/><\/figure><\/div>\n\n\n<p><strong>45 \u5982\u4f55\u6253\u4e71\u4e00\u4e2a\u5217\u8868\u7684\u5143\u7d20\uff1f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"222\" height=\"113\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-88.png\" alt=\"\" class=\"wp-image-3235\"\/><\/figure><\/div>\n\n\n<p><strong>46. \u5b57\u5178\u64cd\u4f5c\u4e2d del \u548c pop \u6709\u4ec0\u4e48\u533a\u522b <\/strong><\/p>\n\n\n<p>pop\u5728\u5220\u9664\u540e\u8fd4\u56de\u8be5\u5143\u7d20\u7684\u503c\uff0cdel\u76f4\u63a5\u5220\u9664\uff0c\u53e6\u5916\u4e8c\u8005\u901f\u5ea6\u4e0a\u6ca1\u6709\u53bb\u5f88\u5927\u533a\u522b\uff08\u5c3d\u7ba1del\u76f8\u5bf9pop\u6709\u4e00\u4e22\u4e22\u4f18\u52bf\uff09<\/p>\n\n\n<p><strong>47. \u6309\u7167\u5b57\u5178\u7684\u5185\u7684\u5e74\u9f84\u6392\u5e8f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"627\" height=\"309\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-89.png\" alt=\"\" class=\"wp-image-3236\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-89.png 627w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-89-300x148.png 300w\" sizes=\"(max-width: 627px) 100vw, 627px\" \/><\/figure><\/div>\n\n\n<p><strong>48. \u8bf7\u5408\u5e76\u4e0b\u9762\u4e24\u4e2a\u5b57\u5178 a = {&#8220;A&#8221;:1,&#8221;B&#8221;:2},b = {&#8220;C&#8221;:3,&#8221;D&#8221;:4} <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"262\" height=\"121\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-90.png\" alt=\"\" class=\"wp-image-3237\"\/><\/figure><\/div>\n\n\n<p><strong>49. \u5982\u4f55\u4f7f\u7528\u751f\u6210\u5f0f\u7684\u65b9\u5f0f\u751f\u6210\u4e00\u4e2a\u5b57\u5178\uff0c\u5199\u4e00\u6bb5\u529f\u80fd\u4ee3\u7801\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"316\" height=\"85\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-91.png\" alt=\"\" class=\"wp-image-3238\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-91.png 316w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-91-300x81.png 300w\" sizes=\"(max-width: 316px) 100vw, 316px\" \/><\/figure><\/div>\n\n\n<p><strong>50. \u5982\u4f55\u628a\u5143\u7ec4(&#8220;a&#8221;,&#8221;b&#8221;)\u548c\u5143\u7ec4(1,2)\uff0c\u53d8\u4e3a\u5b57\u5178{&#8220;a&#8221;:1,&#8221;b&#8221;:2} <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"201\" height=\"111\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-92.png\" alt=\"\" class=\"wp-image-3239\"\/><\/figure><\/div>\n\n\n<p>\u5173\u4e8ezip\uff1a<\/p>\n\n\n<p><strong>zip()<\/strong> \u51fd\u6570\u7528\u4e8e\u5c06\u53ef\u8fed\u4ee3\u7684\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u5c06\u5bf9\u8c61\u4e2d\u5bf9\u5e94\u7684\u5143\u7d20\u6253\u5305\u6210\u4e00\u4e2a\u4e2a\u5143\u7ec4\uff0c\u7136\u540e\u8fd4\u56de\u7531\u8fd9\u4e9b\u5143\u7ec4\u7ec4\u6210\u7684\u5217\u8868\u3002\u5982\u679c\u5404\u4e2a\u8fed\u4ee3\u5668\u7684\u5143\u7d20\u4e2a\u6570\u4e0d\u4e00\u81f4\uff0c\u5219\u8fd4\u56de\u5217\u8868\u957f\u5ea6\u4e0e\u6700\u77ed\u7684\u5bf9\u8c61\u76f8\u540c\uff0c\u5229\u7528 * \u53f7\u64cd\u4f5c\u7b26\uff0c\u53ef\u4ee5\u5c06\u5143\u7ec4\u89e3\u538b\u4e3a\u5217\u8868\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"210\" height=\"216\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-93.png\" alt=\"\" class=\"wp-image-3240\"\/><\/figure><\/div>\n\n\n<p><strong>51. Python \u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\u7684\u7c7b\u578b\u53ca\u5176\u7279\u6027\uff1f <\/strong><\/p>\n\n\n<p>\u00bf\u5565 \u662f\u8fd9\u4e2a\u5417<\/p>\n\n\n<ul><li>int \u5b58\u6574\u6570<\/li><li>float \u5b58\u6d6e\u70b9\u6570<\/li><li>list \u5b58\u5217\u8868<\/li><li>tuple \u5b58\u5143\u7ec4<\/li><li>dict \u5b58\u5b57\u5178<\/li><\/ul>\n\n\n<p><strong>52. \u5982\u4f55\u4ea4\u6362\u5b57\u5178{&#8220;A&#8221;:1,&#8221;B&#8221;:2}\u7684\u952e\u548c\u503c\uff1f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"277\" height=\"99\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-96.png\" alt=\"\" class=\"wp-image-3243\"\/><\/figure><\/div>\n\n\n<p><strong>53. Python \u91cc\u9762\u5982\u4f55\u5b9e\u73b0 tuple \u548c list \u7684\u8f6c\u6362\uff1f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"166\" height=\"123\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-95.png\" alt=\"\" class=\"wp-image-3242\"\/><\/figure><\/div>\n\n\n<p><strong>54. \u6211\u4eec\u77e5\u9053\u5bf9\u4e8e\u5217\u8868\u53ef\u4ee5\u4f7f\u7528\u5207\u7247\u64cd\u4f5c\u8fdb\u884c\u90e8\u5206\u5143\u7d20\u7684\u9009\u62e9\uff0c\u90a3\u4e48\u5982\u4f55\u5bf9\u751f\u6210\u5668\u7c7b\u578b\u7684\u5bf9\u8c61\u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\u5462\uff1f <\/strong><\/p>\n\n\n<p>\u8fd9\u9053\u9898\u8003\u5bdfitertools\u7684islice\u3002<\/p>\n\n\n<p> iterable[start : stop : step]\uff0c  \u521b\u5efa\u4e00\u4e2a\u8fed\u4ee3\u5668\uff0c\u8df3\u8fc7\u524dstart\u4e2a\u9879\uff0c\u8fed\u4ee3\u5728stop\u6240\u6307\u5b9a\u7684\u4f4d\u7f6e\u505c\u6b62\uff0cstep\u6307\u5b9a\u7528\u4e8e\u8df3\u8fc7\u9879\u7684\u6b65\u5e45\u3002\u8fed\u4ee3\u9ed8\u8ba4\u5c06\u4ece0\u5f00\u59cb\uff0c\u6b65\u5e45\u9ed8\u8ba41 \uff08\u662f\u4e0d\u662f\u548c\u5207\u7247\u5f88\u50cf\uff1f\uff09<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"241\" height=\"126\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-97.png\" alt=\"\" class=\"wp-image-3247\"\/><\/figure><\/div>\n\n\n<p><strong>55. \u8bf7\u5c06[i for i in range(3)]\u6539\u6210\u751f\u6210\u5668 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"117\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-98.png\" alt=\"\" class=\"wp-image-3248\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-98.png 398w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-98-300x88.png 300w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/figure><\/div>\n\n\n<p><strong>56. a=\u201chello\u201d \u548c b=\u201c\u4f60\u597d\u201d \u7f16\u7801\u6210 bytes \u7c7b\u578b <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"274\" height=\"179\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-99.png\" alt=\"\" class=\"wp-image-3249\"\/><\/figure><\/div>\n\n\n<p><strong>57.  \u4e0b\u9762\u7684\u4ee3\u7801\u8f93\u51fa\u7ed3\u679c\u662f\u4ec0\u4e48\uff1f <\/strong><\/p>\n\n\n<p> <strong>a = (1,2,3,[4,5,6,7],8)<br \/> a[2] = 2 <\/strong><\/p>\n\n\n<p>\u5143\u7ec4\u4e0d\u80fd\u66f4\u6539\uff0c\u62a5\u9519\u3002<\/p>\n\n\n<p><strong>58. \u4e0b\u9762\u7684\u4ee3\u7801\u8f93\u51fa\u7684\u7ed3\u679c\u662f\u4ec0\u4e48? <\/strong><\/p>\n\n\n<p><strong> a = (1,2,3,[4,5,6,7],8)<br \/> a[3][0] = 2 <\/strong><\/p>\n\n\n<p> (1,2,3,[2,5,6,7],8) \u3002\u867d\u7136\u5143\u7ec4\u4e0d\u80fd\u66f4\u6539\uff0c\u4f46\u662f\u5143\u7ec4\u5185\u7684\u6570\u636e\u7c7b\u578b\u5982\u679c\u53ef\u53d8\u7c7b\u578b\u662f\u53ef\u4ee5\u6539\u7684\uff08int\u4e3a\u4e0d\u53ef\u53d8\u7c7b\u578b\uff0clist\u4e3a\u53ef\u53d8\u7c7b\u578b\uff09\u3002<\/p>\n\n\n<p><strong>59. Python \u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u7684\u503c <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"126\" height=\"145\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-100.png\" alt=\"\" class=\"wp-image-3250\"\/><\/figure><\/div>\n\n\n<p><strong>60. \u5728\u8bfb\u6587\u4ef6\u64cd\u4f5c\u7684\u65f6\u5019\u4f1a\u4f7f\u7528 read\u3001readline \u6216\u8005 readlines\uff0c\u7b80\u8ff0\u5b83\u4eec\u5404\u81ea\u7684\u4f5c\u7528 <\/strong><\/p>\n\n\n<p>read\u662f\u5c06\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u4ee5\u5b57\u7b26\u4e32\u7684\u5f62\u5f0f\u5b58\u51fa\u6765\uff0c\u591a\u884c\u4e2d\u7528\\n\u5206\u5272\uff0c\u4f46\u662f\u5bf9\u4e8e\u8f83\u5927\u6587\u4ef6\u9700\u8981\u5f88\u5927\u7684\u5185\u5b58\u3002<\/p>\n\n\n<p>readline\u662f\u4e00\u6b21\u8bfb\u53d6\u4e00\u884c\uff0c\u4f46\u662f\u76f8\u5bf9\u4e8ereadlines\u6162\u3002<\/p>\n\n\n<p>readlines\u662f\u5c06\u6587\u4ef6\u884c\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u8fd4\u56de\u3002<\/p>\n\n\n<p><strong>61.json \u5e8f\u5217\u5316\u65f6\uff0c\u53ef\u4ee5\u5904\u7406\u7684\u6570\u636e\u7c7b\u578b\u6709\u54ea\u4e9b\uff1f\u5982\u4f55\u5b9a\u5236\u652f\u6301 datetime \u7c7b\u578b\uff1f <\/strong><\/p>\n\n\n<p>\u53ef\u4ee5\u5904\u7406\u6240\u6709python\u7684\u81ea\u5e26\u6570\u636e\u7c7b\u578b\uff08\u6216\u81ea\u52a8\u8f6c\u6362\u5230\u53ef\u5904\u7406\u7c7b\u578b\uff09<\/p>\n\n\n<pre class=\"wp-block-code\"><code>from datatime import datatimd\ndatatime.strftime('%Y-%m-%d %H:%M:%S')<\/code><\/pre>\n\n\n<p><strong>62. json \u5e8f\u5217\u5316\u65f6\uff0c\u9ed8\u8ba4\u9047\u5230\u4e2d\u6587\u4f1a\u8f6c\u6362\u6210 unicode\uff0c\u5982\u679c\u60f3\u8981\u4fdd\u7559\u4e2d\u6587\u600e\u4e48\u529e\uff1f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"304\" height=\"94\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-101.png\" alt=\"\" class=\"wp-image-3251\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-101.png 304w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-101-300x93.png 300w\" sizes=\"(max-width: 304px) 100vw, 304px\" \/><\/figure><\/div>\n\n\n<p><strong>63. \u6709\u4e24\u4e2a\u78c1\u76d8\u6587\u4ef6 A \u548c B\uff0c\u5404\u5b58\u653e\u4e00\u884c\u5b57\u6bcd\uff0c\u8981\u6c42\u628a\u8fd9\u4e24\u4e2a\u6587\u4ef6\u4e2d\u7684\u4fe1\u606f\u5408\u5e76(\u6309\u5b57\u6bcd\u987a\u5e8f\u6392\u5217)\uff0c\u8f93\u51fa\u5230\u4e00\u4e2a\u65b0\u6587\u4ef6 C \u4e2d\u3002 <\/strong><\/p>\n\n\n<p>\u8bfb\u5199\u6587\u4ef6\u5c31\u4e0d\u5199\u4e86\uff0cwith open() as f \uff0c\u7136\u540e\u5206\u522bread\u548cwrite<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"166\" height=\"134\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-102.png\" alt=\"\" class=\"wp-image-3252\"\/><\/figure><\/div>\n\n\n<p><strong>64. \u5982\u679c\u5f53\u524d\u7684\u65e5\u671f\u4e3a 20190530\uff0c\u8981\u6c42\u5199\u4e00\u4e2a\u51fd\u6570\u8f93\u51fa N \u5929\u540e\u7684\u65e5\u671f\uff0c(\u6bd4\u5982 N \u4e3a 2\uff0c\u5219\u8f93\u51fa 20190601)\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"532\" height=\"206\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-103.png\" alt=\"\" class=\"wp-image-3253\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-103.png 532w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-103-300x116.png 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/figure><\/div>\n\n\n<p><strong>65. \u5199\u4e00\u4e2a\u51fd\u6570\uff0c\u63a5\u6536\u6574\u6570\u53c2\u6570 n\uff0c\u8fd4\u56de\u4e00\u4e2a\u51fd\u6570\uff0c\u51fd\u6570\u7684\u529f\u80fd\u662f\u628a\u51fd\u6570\u7684\u53c2\u6570\u548c n \u76f8\u4e58\u5e76\u628a\u7ed3\u679c\u8fd4\u56de\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"235\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-104.png\" alt=\"\" class=\"wp-image-3256\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-104.png 394w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-104-300x179.png 300w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/figure><\/div>\n\n\n<p><strong>66. \u4e0b\u9762\u4ee3\u7801\u4f1a\u5b58\u5728\u4ec0\u4e48\u95ee\u9898\uff0c\u5982\u4f55\u6539\u8fdb\uff1f <\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><code>def strappend(num)\uff1a\n    str='first'\n    for i in range(num)\uff1a\n        str+=str(i)\n    return str<\/code><\/pre>\n\n\n<p>\u9996\u5148\u547d\u540d\u4e0d\u89c4\u8303\uff0c\u5176\u6b21\u7531\u4e8estr\u662f\u4e0d\u53ef\u53d8\u7c7b\u578b\uff0c\u6bcf\u6b21\u5faa\u73af\u90fd\u4ea7\u751f\u65b0\u7684\u5bf9\u8c61\u6d6a\u8d39\uff0c\u5e94\u8be5\u5217\u8868\u8f6c\u6362\u3002<\/p>\n\n\n<p><strong>67. \u4e00\u884c\u4ee3\u7801\u8f93\u51fa 1-100 \u4e4b\u95f4\u7684\u6240\u6709\u5076\u6570\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"443\" height=\"88\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-105.png\" alt=\"\" class=\"wp-image-3257\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-105.png 443w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-105-300x60.png 300w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"448\" height=\"85\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-106.png\" alt=\"\" class=\"wp-image-3258\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-106.png 448w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-106-300x57.png 300w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/figure><\/div>\n\n\n<p><strong>68. with \u8bed\u53e5\u7684\u4f5c\u7528\uff0c\u5199\u4e00\u6bb5\u4ee3\u7801\uff1f <\/strong><\/p>\n\n\n<pre class=\"wp-block-preformatted\">with open('xxx','w') as f:<br \/>    f.write('xxx')<\/pre>\n\n\n<p>\u4f1a\u81ea\u52a8\u8c03\u7528close\u65b9\u6cd5\uff0c\u4e0d\u518d\u9700\u8981\u624b\u52a8\u8c03\u7528\uff08\u8be6\u89c1\u7b2c\u4e09\u9898\uff09<\/p>\n\n\n<p><strong>69. python \u5b57\u5178\u548c json \u5b57\u7b26\u4e32\u76f8\u4e92\u8f6c\u5316\u65b9\u6cd5 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"213\" height=\"285\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-108.png\" alt=\"\" class=\"wp-image-3260\"\/><\/figure><\/div>\n\n\n<p><strong>70. \u8bf7\u5199\u4e00\u4e2a Python \u903b\u8f91\uff0c\u8ba1\u7b97\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\u7684\u5927\u5199\u5b57\u6bcd\u6570\u91cf <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"252\" height=\"183\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-107.png\" alt=\"\" class=\"wp-image-3259\"\/><\/figure><\/div>\n\n\n<p><strong>71. \u8bf7\u5199\u4e00\u6bb5 Python\u8fde\u63a5 Mongo \u6570\u636e\u5e93\uff0c\u7136\u540e\u7684\u67e5\u8be2\u4ee3\u7801\u3002 <\/strong><\/p>\n\n\n<p>\u7565\u3002<\/p>\n\n\n<p><strong>72. \u8bf4\u4e00\u8bf4 Redis \u7684\u57fa\u672c\u7c7b\u578b\u3002 <\/strong><\/p>\n\n\n<p>\u6709\u4e94\u79cd\u7c7b\u578b\uff1a<\/p>\n\n\n<ul><li>String\uff08\u5b57\u7b26\u4e32\uff09<\/li><li>Hash\uff08\u54c8\u5e0c\uff09<\/li><li>List\uff08\u5217\u8868\uff09<\/li><li>Set\uff08\u96c6\u5408\uff09<\/li><li>ZSet\uff08\u6709\u5e8f\u96c6\u5408\uff09<\/li><\/ul>\n\n\n<p><strong>73. \u8bf7\u5199\u4e00\u6bb5 Python\u8fde\u63a5 Redis \u6570\u636e\u5e93\u7684\u4ee3\u7801\u3002 <\/strong><\/p>\n\n\n<p>\u73b0\u5728\u7535\u8111\u6ca1\u6709redis\u73af\u5883\uff0c\u4ee5\u540e\u8865x\u3002<\/p>\n\n\n<p><strong>74. \u8bf7\u5199\u4e00\u6bb5 Python \u8fde\u63a5 MySQL \u6570\u636e\u5e93\u7684\u4ee3\u7801\u3002 <\/strong><\/p>\n\n\n<p>\u7565\u3002<\/p>\n\n\n<p><strong>75. \u4e86\u89e3 Redis \u7684\u4e8b\u52a1\u4e48\uff1f <\/strong><\/p>\n\n\n<p> \u4e8b\u52a1\u63d0\u4f9b\u4e86\u4e00\u79cd&#8221;\u5c06\u591a\u4e2a\u547d\u4ee4\u6253\u5305\uff0c\u4e00\u6b21\u6027\u63d0\u4ea4\u5e76\u6309\u987a\u5e8f\u6267\u884c&#8221;\u7684\u673a\u5236\uff0c\u63d0\u4ea4\u540e\u5728\u4e8b\u52a1\u6267\u884c\u4e2d\u4e0d\u4f1a\u4e2d\u65ad\u3002\u53ea\u6709\u5728\u6267\u884c\u5b8c\u6240\u6709\u547d\u4ee4\u540e\u624d\u4f1a\u7ee7\u7eed\u6267\u884c\u6765\u81ea\u5176\u4ed6\u5ba2\u6237\u7684\u6d88\u606f\u3002 <\/p>\n\n\n<p>\u7c7b\u4f3c\u4e8e\u6279\u5904\u7406+\u8d44\u6e90\u9501\u3002<\/p>\n\n\n<p><strong>76. \u4e86\u89e3\u6570\u636e\u5e93\u7684\u4e09\u8303\u5f0f\u4e48\uff1f <\/strong><\/p>\n\n\n<p>\u4e00\u8303\u5f0f\uff1a \u4efb\u7ed9\u5173\u7cfbR\uff0c\u5982\u679cR\u4e2d\u6bcf\u4e2a\u5217\u4e0e\u884c\u5bf9\u5e94\u5355\u5143\u683c\u7684\u6570\u636e\u90fd\u662f\u4e0d\u53ef\u518d\u5206\u7684\u57fa\u672c\u5143\u7d20\uff0c\u5219R\u8fbe\u5230\u7b2c\u4e00\u8303\u5f0f\uff0c\u7b80\u79f01NF\u3002 \uff08\u6700\u57fa\u672c\u7684\u8303\u5f0f\uff09<\/p>\n\n\n<p>\u4e8c\u8303\u5f0f\uff1a \u5982\u679c\u4e00\u4e2a\u5173\u7cfb\u8fbe\u5230\u7b2c\u4e00\u8303\u5f0f\uff0c\u4e14\u4e0d\u5b58\u5728\u4efb\u4f55\u975e\u4e3b\u5c5e\u6027\u5bf9\u5019\u9009\u5173\u952e\u5b57\u7684\u90e8\u5206\u51fd\u6570\u4f9d\u8d56\uff0c\u5219\u79f0\u5173\u7cfb\u8fbe\u5230\u7b2c\u4e8c\u8303\u5f0f\uff0c2NF\u3002 \uff08\u5176\u4ed6\u9879\u5747\u4e0e\u4e3b\u952e\u6709\u5173\uff09<\/p>\n\n\n<p>\u4e09\u8303\u5f0f\uff1a \u5982\u679c\u4e00\u4e2a\u5173\u7cfb\u8fbe\u5230\u7b2c\u4e8c\u8303\u5f0f\u4e14\u4e0d\u5b58\u5728\u975e\u4e3b\u5c5e\u6027\u5bf9\u5019\u9009\u5173\u952e\u5b57\u7684\u4f20\u9012\u51fd\u6570\u4f9d\u8d56\uff0c\u5219\u79f0\u4e3a\u8fbe\u5230\u7b2c\u4e09\u8303\u5f0f\uff0c\u7b80\u79f03NF\u3002 \uff08\u7ea6\u675f\u5916\u952e\uff0c\u901a\u8fc7\u5916\u952e\u67e5\u8be2\u4fe1\u606f\uff09<\/p>\n\n\n<p><strong>77. \u4e86\u89e3\u5206\u5e03\u5f0f\u9501\u4e48\uff1f <\/strong><\/p>\n\n\n<p> \u5229\u7528\u8bf8\u5982zookeeper\uff0credis\u7b49\u66f4\u9ad8\u6548\u7684\u5206\u5e03\u5f0f\u7ec4\u4ef6\u6765\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\uff0c\u53ef\u4ee5\u63d0\u4f9b\u9ad8\u53ef\u7528\u7684\u66f4\u5f3a\u58ee\u7684\u9501\u7279\u6027\uff0c\u5e76\u4e14\u652f\u6301\u4e30\u5bcc\u5316\u7684\u4f7f\u7528\u573a\u666f\u3002 <\/p>\n\n\n<p><strong>78. \u7528 Python \u5b9e\u73b0\u4e00\u4e2a Reids \u7684\u5206\u5e03\u5f0f\u9501\u7684\u529f\u80fd\u3002 <\/strong><\/p>\n\n\n<p>\u7565\u3002<\/p>\n\n\n<p><strong>79. \u5199\u4e00\u6bb5 Python \u4f7f\u7528 Mongo \u6570\u636e\u5e93\u521b\u5efa\u7d22\u5f15\u7684\u4ee3\u7801\u3002 <\/strong><\/p>\n\n\n<p>\u7565\u3002<\/p>\n\n\n<p><strong>80. \u51fd\u6570\u88c5\u9970\u5668\u6709\u4ec0\u4e48\u4f5c\u7528\uff1f\u8bf7\u5217\u4e3e\u8bf4\u660e\uff1f <\/strong><\/p>\n\n\n<p>\u88c5\u9970\u5668\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a Python \u51fd\u6570\uff0c\u5b83\u53ef\u4ee5\u8ba9\u5176\u4ed6\u51fd\u6570\u5728\u4e0d\u9700\u8981\u505a\u4efb\u4f55\u4ee3\u7801\u53d8\u52a8\u7684\u524d\u63d0\u4e0b\u589e\u52a0\u989d\u5916\u529f\u80fd\uff0c\u88c5\u9970\u5668\u7684\u8fd4\u56de\u503c\u4e5f\u662f\u4e00\u4e2a\u51fd\u6570\u5bf9\u8c61\u3002<br \/>         \u5b83\u7ecf\u5e38\u7528\u4e8e\u6709\u5207\u9762\u9700\u6c42\u7684\u573a\u666f\uff0c\u6bd4\u5982\uff1a\u63d2\u5165\u65e5\u5fd7\u3001\u6027\u80fd\u6d4b\u8bd5\u3001\u4e8b\u52a1\u5904\u7406\u3001\u7f13\u5b58\u3001\u6743\u9650\u6821\u9a8c\u7b49\u573a\u666f\u3002<br \/>         \u6709\u4e86\u88c5\u9970\u5668\uff0c\u5c31\u53ef\u4ee5\u62bd\u79bb\u51fa\u5927\u91cf\u4e0e\u51fd\u6570\u529f\u80fd\u672c\u8eab\u65e0\u5173\u7684\u96f7\u540c\u4ee3\u7801\u5e76\u7ee7\u7eed\u91cd\u7528\u3002<\/p>\n\n\n<p><strong>81. Python \u5783\u573e\u56de\u6536\u673a\u5236\uff1f <\/strong><\/p>\n\n\n<p>Python\u7684\u5783\u573e\u56de\u6536\u673a\u5236\u5341\u5206\u7c7b\u4f3c\u4e8e<a rel=\"noreferrer noopener\" aria-label=\"java\u7684\u5783\u573e\u56de\u6536\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"http:\/\/www.sniper97.cn\/index.php\/note\/jvm\/1377\/\" target=\"_blank\">java\u7684\u5783\u573e\u56de\u6536<\/a>\uff0c\u4f46\u662fPython\u7684\u5783\u573e\u56de\u6536\u5e76\u6ca1\u6709java\u7684\u90a3\u4e48\u591a\u79cd\uff0cpython\u53ea\u6709\u5f15\u7528\u8ba1\u6570\u5668\u548c\u5206\u4ee3\u56de\u6536\u3001\u6807\u8bb0\u6e05\u9664\u3002<\/p>\n\n\n<p><strong>82. \u9b54\u6cd5\u51fd\u6570 call\u600e\u4e48\u4f7f\u7528? <\/strong><\/p>\n\n\n<p>call\u7684\u5b58\u5728\u5141\u8bb8\u4e86\u5bf9\u8c61\u5f53\u4f5c\u65b9\u6cd5\u6765\u8fdb\u884c\u4f7f\u7528\uff0c\u6bd4\u5982\u4e0b\u9762\u7684sum()\uff0c\u867d\u7136sum\u7684\u5bf9\u8c61\uff0c\u4f46\u662f\u4f9d\u7136\u4f1a\u8c03\u7528call\u6765\u8fdb\u884c\u76f8\u5173\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>class Sum:\n    def __init__(self, x, y):\n        self._x = x\n        self._y = y\n    def add(self):\n        return self._x + self._y\n    def __call__(self):\n        return self.add()\nsum = Sum(1, 2)\nprint(sum.add())\nprint(sum())\nprint(callable(sum))<\/code><\/pre>\n\n\n<p>\u8f93\u51fa\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>3\n3\nTrue<\/code><\/pre>\n\n\n<p><strong>83. \u5982\u4f55\u5224\u65ad\u4e00\u4e2a\u5bf9\u8c61\u662f\u51fd\u6570\u8fd8\u662f\u65b9\u6cd5\uff1f <\/strong><\/p>\n\n\n<p>\u4f7f\u7528type\uff0c\u65b9\u6cd5\u8f93\u51fa\u5e94\u8be5\u662ffunction\uff0c\u800c\u5bf9\u8c61\u5219\u662f__main__.\u5bf9\u8c61\u540d\u3002<\/p>\n\n\n<p><strong>84. @classmethod \u548c@staticmethod \u7528\u6cd5\u548c\u533a\u522b <\/strong><\/p>\n\n\n<p>classmethod\u7528\u6765\u5b9a\u4e49\u7c7b\u65b9\u6cd5\uff0c\u800cstaticmethod\u7528\u6765\u5b9a\u4e49\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n\n\n<p>\u4f7f\u7528\u4e0a\u4e24\u79cd\u90fd\u53ef\u4ee5\u4f7f\u7528\u7c7b\u540d.\u65b9\u6cd5\u540d\u6765\u8fdb\u884c\u8c03\u7528\uff0c\u4f46\u662fcalssmethod\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u4ee5\u4e0a\u53c2\u6570\uff08cls\uff09\uff0c \u8fd9\u4e2a\u53c2\u6570\u8868\u793a\u81ea\u8eab\u7c7b\uff0c\u53ef\u4ee5\u7528\u5b83\u6765\u5bf9\u65b9\u6cd5\u5185\u7684\u65b9\u6cd5\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n\n\n<p><strong>85. Python \u4e2d\u7684\u63a5\u53e3\u5982\u4f55\u5b9e\u73b0\uff1f <\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><code>from abc import ABCMeta,abstractmethod\nclass interface(object):\n    __metaclass__ = ABCMeta #\u6307\u5b9a\u8fd9\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b\n    @abstractmethod  #\u62bd\u8c61\u65b9\u6cd5\n    def Lee(self):\n        pass\n    def Marlon(self):\n        pass<\/code><\/pre>\n\n\n<p>\u4f46\u662f\u9700\u8981\u6ce8\u610f\u7684\u662f\u63a5\u53e3\u7684\u7ee7\u627f\u7c7b\u5fc5\u987b\u590d\u5199\u6240\u6709\u65b9\u6cd5\uff0c\u6240\u4ee5\u53ef\u80fd\u8fd8\u4e0d\u5982\u7ee7\u627f\u597d\u7528\u3002<\/p>\n\n\n<p><strong>86. Python \u4e2d\u7684\u53cd\u5c04\u4e86\u89e3\u4e48? <\/strong><\/p>\n\n\n<p> \u53cd\u5c04\u662f\u5728\u53ea\u77e5\u9053\u7c7b\u540d\u6216\u8005\u51fd\u6570\u540d\u7684\u60c5\u51b5\u4e0b\u8c03\u7528\u5176\u5bf9\u5e94\u7684\u51fd\u6570\u3002 <\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"270\" height=\"452\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-126.png\" alt=\"\" class=\"wp-image-3292\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-126.png 270w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-126-179x300.png 179w\" sizes=\"(max-width: 270px) 100vw, 270px\" \/><\/figure><\/div>\n\n\n<p><strong>87. metaclass \u4f5c\u7528\uff1f\u4ee5\u53ca\u5e94\u7528\u573a\u666f\uff1f <\/strong><\/p>\n\n\n<p>metaclass\u5141\u8bb8\u7236\u7c7b\u5bf9\u5b50\u7c7b\u8fdb\u884c\u4fee\u6539\uff0c\u4e00\u822c\u7528\u5728\u6846\u67b6\u5f00\u53d1\u3002\u7531\u4e8e\u4e0d\u63a8\u8350\u4f7f\u7528\u6240\u4ee5\u4e0d\u505a\u8fc7\u591a\u4ecb\u7ecd\u3002<\/p>\n\n\n<p><strong>88. hasattr() getattr() setattr()\u7684\u7528\u6cd5 <\/strong><\/p>\n\n\n<p>\u5e38\u7528\u5728python\u7684\u53cd\u5c04\uff0c86\u9898\u5168\u90e8\u7528\u8fc7\u8fd9\u51e0\u79cd\u65b9\u6cd5\uff0c\u79fb\u6b6586\u9898\u3002<\/p>\n\n\n<p><strong>89. \u8bf7\u5217\u4e3e\u4f60\u77e5\u9053\u7684 Python \u7684\u9b54\u6cd5\u65b9\u6cd5\u53ca\u7528\u9014\u3002 <\/strong><\/p>\n\n\n<ul><li>init\uff1a\u6784\u9020\u51fd\u6570<\/li><li>del\uff1a\u6790\u6784\u51fd\u6570<\/li><li>setattr\uff1a\u8bbe\u7f6e\u53c2\u6570<\/li><li>getattr\uff1a\u83b7\u5f97\u53c2\u6570<\/li><li>delattr\uff1a\u5220\u9664\u53c2\u6570<\/li><li>\u00b7\u00b7\u00b7<\/li><\/ul>\n\n\n<p><strong>90. \u5982\u4f55\u77e5\u9053\u4e00\u4e2a Python \u5bf9\u8c61\u7684\u7c7b\u578b\uff1f <\/strong><\/p>\n\n\n<p>type\uff08\uff09<\/p>\n\n\n<p><strong>91. Python \u7684\u4f20\u53c2\u662f\u4f20\u503c\u8fd8\u662f\u4f20\u5740\uff1f <\/strong><\/p>\n\n\n<p>\u8fd9\u53d6\u51b3\u4e8e\u662f\u4ec0\u4e48\u7c7b\u578b\uff0c\u5982\u679c\u662f\u53ef\u53d8\u7c7b\u578b\u5c31\u4f20\u9012\u503c\uff0c\u5982\u679c\u662f\u4e0d\u53ef\u53d8\u7c7b\u578b\u5c31\u4f20\u53c2\u3002<\/p>\n\n\n<p><strong>92. Python \u4e2d\u7684\u5143\u7c7b(metaclass)\u4f7f\u7528\u4e3e\u4f8b <\/strong><\/p>\n\n\n<p>\u5143\u7c7b\u5c31\u662f\u751f\u6210\u7c7b\u7684\u5de5\u5177\uff0cpython\u6700\u57fa\u7840\u7684\u5143\u7c7b\u662ftype\uff08\u4e5f\u5c31\u662f\u53ef\u4ee5\u7528type\u6765\u751f\u6210\u7c7b\uff09\uff0c\u540c\u6837\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u590d\u5199 __metaclass__\u5c5e\u6027\u6765\u4f7f\u5f53\u524d\u7c7b\u53d8\u6210\u5143\u7c7b\u3002<\/p>\n\n\n<p><strong>93. \u7b80\u8ff0 any()\u548c all()\u65b9\u6cd5 <\/strong><\/p>\n\n\n<p>any\u65b9\u6cd5\u4f1a\u76d1\u6d4b\u8fd9\u91cc\u9762\u662f\u5426\u6709\u975e0\uff080\u3001False\u3001\u7a7a\uff09\uff0c\u5982\u679c\u6709\u8fd4\u56deTrue\uff0c\u5982\u679c\u6ca1\u6709\u8fd4\u56deFalse\u3002<\/p>\n\n\n<p>all\u65b9\u6cd5\u68c0\u6d4b\u662f\u5426\u5168\u4e3a0\uff080\u3001False\u3001\u7a7a\uff09\uff0c\u5982\u679c\u5168\u7a7a\u8fd4\u56deTrue\uff0c\u53cd\u4e4bFalse\u3002<\/p>\n\n\n<p><strong>94. filter \u65b9\u6cd5\u6c42\u51fa\u5217\u8868\u6240\u6709\u5947\u6570\u5e76\u6784\u9020\u65b0\u5217\u8868\uff0ca = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] <\/strong><\/p>\n\n\n<p>filter()&nbsp;\u51fd\u6570\u7528\u4e8e\u8fc7\u6ee4\u5e8f\u5217\uff0c\u8fc7\u6ee4\u6389\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u5143\u7d20\uff0c\u8fd4\u56de\u7531\u7b26\u5408\u6761\u4ef6\u5143\u7d20\u7ec4\u6210\u7684\u65b0\u5217\u8868\u3002\u63a5\u6536\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u4e3a\u51fd\u6570\uff0c\u7b2c\u4e8c\u4e2a\u4e3a\u5e8f\u5217\uff0c\u5e8f\u5217\u7684\u6bcf\u4e2a\u5143\u7d20\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u51fd\u6570\u8fdb\u884c\u5224\uff0c\u7136\u540e\u8fd4\u56de True \u6216 False\uff0c\u6700\u540e\u5c06\u8fd4\u56de True \u7684\u5143\u7d20\u653e\u5230\u65b0\u5217\u8868\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"293\" height=\"113\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-133.png\" alt=\"\" class=\"wp-image-3311\"\/><\/figure><\/div>\n\n\n<p><strong>95. \u4ec0\u4e48\u662f\u7334\u5b50\u8865\u4e01\uff1f <\/strong><\/p>\n\n\n<p> \u5728\u8fd0\u884c\u671f\u95f4\u52a8\u6001\u4fee\u6539\u4e00\u4e2a\u7c7b\u6216\u6a21\u5757\u3002 <\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"231\" height=\"236\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-134.png\" alt=\"\" class=\"wp-image-3312\"\/><\/figure><\/div>\n\n\n<p><strong>96. \u5728 Python \u4e2d\u662f\u5982\u4f55\u7ba1\u7406\u5185\u5b58\u7684\uff1f <\/strong><\/p>\n\n\n<p>python\u4f7f\u7528\u4e86\u4e00\u4e2a\u5185\u5b58\u6c60\u53eb\u505a pymalloc  \uff0c\u5b83\u5bf9\u4e8e\u90a3\u4e9b\u5c0f\u4e8e512k\u4ee5\u4e0b\u7684\u5bf9\u8c61\u5728pymalloc\u4e2d\u5206\u914d\u7a7a\u95f4\uff0c\u9632\u6b62\u9891\u7e41\u7684\u4f7f\u7528C\u8bed\u8a00\u7684malloc\u548cfree\u9020\u6210\u7684\u7cfb\u7edf\u5f00\u9500\u3002\u5bf9\u4e8e\u5927\u4e8e512k\u7684\u4f9d\u7136\u4ea4\u7ed9\u7cfb\u7edf\u7684malloc\u6765\u5904\u7406\u3002<\/p>\n\n\n<p>\u7136\u540e\u5229\u7528\u5f15\u7528\u8ba1\u6570\u5668\u3001\u6807\u8bb0-\u6e05\u9664\u7b49\u7b97\u6cd5\u8fdb\u884c\u5783\u573e\u5904\u7406\u3002<\/p>\n\n\n<p><strong>97. \u5f53\u9000\u51fa Python \u65f6\u662f\u5426\u91ca\u653e\u6240\u6709\u5185\u5b58\u5206\u914d\uff1f <\/strong><\/p>\n\n\n<p>\u4e0d\u4f1a\uff0c\u4f1a\u4fdd\u7559\u4e00\u90e8\u5206\u5168\u5c40\u53d8\u91cf\u7a7a\u95f4\u3002<\/p>\n\n\n<p><strong>98. 1.\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u51fa&lt;html&gt;&lt;h1&gt;\u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053&lt;\/html&gt;\u4e2d\u7684\u6587\u5b572. a=&#8221;\u5f20\u660e 98 \u5206&#8221;\uff0c\u7528 re.sub\uff0c\u5c06 98 \u66ff\u6362\u4e3a 100 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"355\" height=\"151\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-135.png\" alt=\"\" class=\"wp-image-3315\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-135.png 355w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-135-300x128.png 300w\" sizes=\"(max-width: 355px) 100vw, 355px\" \/><\/figure><\/div>\n\n\n<p><strong>99. \u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u4e2d(.<\/strong><em><strong>)\u548c(.<\/strong><\/em><strong>?)\u5339\u914d\u533a\u522b\uff1f <\/strong><\/p>\n\n\n<p>?\u4ee3\u8868\u975e\u8d2a\u5a6a\u5339\u914d\u3002\u5373\u53ef\u4ee5\u5339\u914d0\u6b21\u6216\u80051\u6b21\uff0c\u800c.\u53ea\u5339\u914d\u4e00\u4e2a\u4efb\u610f\u5b57\u7b26\u3002<\/p>\n\n\n<p><strong>100. \u5199\u4e00\u6bb5\u5339\u914d\u90ae\u7bb1\u7684\u6b63\u5219\u8868\u8fbe\u5f0f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"387\" height=\"82\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-136.png\" alt=\"\" class=\"wp-image-3316\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-136.png 387w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-136-300x64.png 300w\" sizes=\"(max-width: 387px) 100vw, 387px\" \/><\/figure><\/div>\n\n\n<p><strong>101. \u89e3\u91ca\u4e00\u4e0b python \u4e2d pass \u8bed\u53e5\u7684\u4f5c\u7528\uff1f <\/strong><\/p>\n\n\n<p>\u7a7a\u8bed\u53e5\uff0c\u5f53\u642d\u5efa\u6574\u4f53\u67b6\u6784\u6216\u8005\u786e\u5b9a\u8981\u6709\u8fd9\u4e2a\u65b9\u6cd5\uff08\u5faa\u73af\u3001\u5224\u65ad\u7b49\uff09\u4f46\u662f\u5177\u4f53\u5b9e\u73b0\u8fd8\u6ca1\u60f3\u597d\u6216\u8005\u5f53\u524d\u53ef\u4ee5\u8df3\u8fc7\u65f6\u3002<\/p>\n\n\n<p><strong>102. \u7b80\u8ff0\u4f60\u5bf9 input()\u51fd\u6570\u7684\u7406\u89e3 <\/strong><\/p>\n\n\n<p>input\u63a5\u53d7\u4e00\u4e2a\u6807\u51c6\u8f93\u5165\u6570\u636e\uff0c\u8fd4\u56destring\u7c7b\u578b<\/p>\n\n\n<p><strong>103. python \u4e2d\u7684 is \u548c== <\/strong><\/p>\n\n\n<p>is \u6bd4\u8f83\u5730\u5740\uff08id\uff09\uff0c\u800c==\u6bd4\u8f83\u503c\uff0c\u5bf9\u4e8e\u5bf9\u8c61\u7684\u6bd4\u8f83\uff0c\u53ef\u4ee5\u5728\u7c7b\u4e2d\u91cd\u8f7d__eq__\u6765\u5b8c\u6210\u5bf9==\u7684\u91cd\u8f7d\u3002<\/p>\n\n\n<p><strong>104. Python \u4e2d\u7684\u4f5c\u7528\u57df <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"322\" height=\"227\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-137.png\" alt=\"\" class=\"wp-image-3319\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-137.png 322w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-137-300x211.png 300w\" sizes=\"(max-width: 322px) 100vw, 322px\" \/><\/figure><\/div>\n\n\n<p><strong>105. \u4e09\u5143\u8fd0\u7b97\u5199\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff1f <\/strong><\/p>\n\n\n<p>\u601d\u8003\u4e0b\u9762\u4e24\u4e2a\u7b49\u4ef7\u793a\u4f8b\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>if a==1:\n    return a\nelse:\n    return b<\/code><\/pre>\n\n\n<pre class=\"wp-block-code\"><code>return a if a==1 else b<\/code><\/pre>\n\n\n<p>\u5728\u4e00\u4e9b\u7b80\u77ed\u7684\u5224\u65ad\u8bed\u53e5\u4e2d\u53ef\u4ee5\u4f7f\u7528\u4e09\u5143\u8fd0\u7b97\u3002<\/p>\n\n\n<p><strong>106. \u4e86\u89e3 enumerate \u4e48\uff1f <\/strong><\/p>\n\n\n<p>\u8be5\u51fd\u6570\u4ed6igong\u4e86\u5c06\u4e00\u4e2a\u53ef\u904d\u5386\u7684\u5bf9\u8c61\u7ec4\u5408\u4e00\u4e2a\u7d22\u5f15\u8fd4\u56de\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"373\" height=\"154\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-138.png\" alt=\"\" class=\"wp-image-3320\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-138.png 373w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-138-300x124.png 300w\" sizes=\"(max-width: 373px) 100vw, 373px\" \/><\/figure><\/div>\n\n\n<p><strong>107. \u5217\u4e3e 5 \u4e2a Python \u4e2d\u7684\u6807\u51c6\u6a21\u5757<\/strong><\/p>\n\n\n<p>\uff1f\u7b2c\u4e00\u9898\u3002<\/p>\n\n\n<p><strong>108. \u5982\u4f55\u5728\u51fd\u6570\u4e2d\u8bbe\u7f6e\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf <\/strong><\/p>\n\n\n<p>global<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"622\" height=\"590\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-139.png\" alt=\"\" class=\"wp-image-3321\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-139.png 622w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-139-300x285.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/figure><\/div>\n\n\n<p><strong>109. pathlib \u7684\u7528\u6cd5\u4e3e\u4f8b <\/strong><\/p>\n\n\n<p> \u7528\u4e8epathlib\u4e2d\u7684Path\u7c7b\u53ef\u4ee5\u521b\u5efapath\u8def\u5f84\u5bf9\u8c61, \u5c5e\u4e8e\u6bd4os.path\u66f4\u9ad8\u62bd\u8c61\u7ea7\u522b\u7684\u5bf9\u8c61  <\/p>\n\n\n<ul><li>Path.suffix  \u6587\u4ef6\u540e\u7f00<\/li><li>Path.stem  \u6587\u4ef6\u540d\u4e0d\u5e26\u540e\u7f00<\/li><li> Path. name  \u5e26\u540e\u7f00\u7684\u5b8c\u6574\u540d\u5b57<\/li><li> Path. parent  \u5e26\u8def\u5f84\u7684\u4e0a\u7ea7\u76ee\u5f55<\/li><\/ul>\n\n\n<p><strong>110. Python \u4e2d\u7684\u5f02\u5e38\u5904\u7406\uff0c\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u573a\u666f <\/strong><\/p>\n\n\n<p>\u4e00\u4e0b\u5b50\u4e5f\u60f3\u4e0d\u51fa\u6bd4\u8f83\u597d\u7684\u4f8b\u5b50\u4e86\uff0c\u4e00\u822c\u5f02\u5e38\u5c31\u662f\u5728\u6587\u4ef6\u5f00\u5173\u3001\u8bf7\u6c42\u6216\u8005\u5bb9\u6613\u4ea7\u751f\u8d8a\u754c\u7684\u5730\u65b9\u4f7f\u7528<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"299\" height=\"149\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-140.png\" alt=\"\" class=\"wp-image-3322\"\/><\/figure><\/div>\n\n\n<p><strong>111. Python \u4e2d\u9012\u5f52\u7684\u6700\u5927\u6b21\u6570\uff0c\u90a3\u5982\u4f55\u7a81\u7834\u5462\uff1f <\/strong><\/p>\n\n\n<p>\u9012\u5f52\u6b21\u6570\u6700\u5927\u4e3a1000\u6b21\uff0c\u4f46\u662f\u8fd9\u5e76\u4e0d\u662f\u51fa\u4e8e\u6027\u80fd\u8003\u8651\u7684\u9650\u5236\uff0c\u800c\u662f\u51fa\u4e8e\u9632\u6b62\u65e0\u9650\u9012\u5f52\u9020\u6210\u5d29\u6e83\u3002<\/p>\n\n\n<p>\u4f7f\u7528\u4e0b\u9762\u4ee3\u7801\u5c31\u53ef\u4ee5\u66f4\u6539\u8fd9\u4e2a\u9650\u5236\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>import sys\nsys.setrecursionlimit(1500)<\/code><\/pre>\n\n\n<p><strong>112. \u4ec0\u4e48\u662f\u9762\u5411\u5bf9\u8c61\u7684 mro <\/strong><\/p>\n\n\n<p>MRO  Method Resoluthion Order  \u65b9\u6cd5\u89e3\u6790\u987a\u5e8f<\/p>\n\n\n<p>\u5b50\u7c7b\u4f18\u4e8e\u7236\u7c7b\uff0c\u81ea\u5b9e\u73b0\u4f18\u4e8e\u7cfb\u7edf\u5b9e\u73b0\u3002\u5bf9\u4e8e\u591a\u7ee7\u627f\u60c5\u51b5\uff0c\u6839\u636e\u7c7b\u7684\u4e0d\u540c\uff08\u5206\u4e3a\u65b0\u5f0f\u7c7b\u548c\u65e7\u5f0f\u7c7b\uff0c\u533a\u5206\u65e7\u5f0f\u65b0\u5f0f\u7c7b\u663e\u793a\u7ee7\u627fObject\uff09\uff0c\u5176\u4e2d\u65b0\u5f0f\u7c7b\u91c7\u7528\u5e7f\u5ea6\u4f18\u5148\u904d\u5386\u6765\u67e5\u627e\u65b9\u6cd5\uff0c\u65e7\u5f0f\u7c7b\u91c7\u7528\u6df1\u5ea6\u4f18\u5148\u904d\u5386\u6765\u67e5\u627e\u65b9\u6cd5\u3002<strong>\u8be6\u89c1116<\/strong><\/p>\n\n\n<p><strong>113. isinstance \u4f5c\u7528\u4ee5\u53ca\u5e94\u7528\u573a\u666f\uff1f <\/strong><\/p>\n\n\n<p>\u83b7\u53d6\u5bf9\u8c61\u7684\u7c7b\u578b\uff0c\u4e3b\u8981\u7528\u6765\u786e\u5b9a\u7c7b\u578b\u662f\u5426\u662f\u9700\u8981\u7684\u7c7b\u578b\u6216\u8005\u6839\u636e\u5bf9\u8c61\u9009\u62e9\u4e0d\u540c\u7684\u5206\u652f\u3002<\/p>\n\n\n<p><strong>114. \u4ec0\u4e48\u662f\u65ad\u8a00\uff1f\u5e94\u7528\u573a\u666f\uff1f <\/strong><\/p>\n\n\n<p>assert\uff0c\u4f1a\u68c0\u67e5assert\u540e\u9762\u7684\u8bed\u53e5\u662f\u5426\u4e3a\u771f\uff0c\u4e3a\u771f\u7ee7\u7eed\u6267\u884c\uff0c\u4e3a\u5047\u629b\u51fa\u5f02\u5e38\u3002\u5e38\u7528\u4e8edebug\u4e2d\u5224\u65ad\u5f53\u524d\u6b65\u7ed3\u679c\u662f\u5426\u5728\u610f\u6599\u4e4b\u4e2d\u3002<\/p>\n\n\n<p><strong>115. lambda \u8868\u8fbe\u5f0f\u683c\u5f0f\u4ee5\u53ca\u5e94\u7528\u573a\u666f\uff1f <\/strong><\/p>\n\n\n<p>\u6bd4\u5982\u5b9a\u4e49\u4e00\u4e2a\u6c42\u4e24\u6570\u548c\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>lambda x, y:x+y<\/code><\/pre>\n\n\n<p>\u5e38\u7528\u4e8e\u7b80\u5355\u65b9\u6cd5\u5e76\u4e14\u4e0d\u9700\u8981\u91cd\u590d\u8c03\u7528\u7684\u60c5\u51b5<\/p>\n\n\n<p><strong>116. \u65b0\u5f0f\u7c7b\u548c\u65e7\u5f0f\u7c7b\u7684\u533a\u522b <\/strong><\/p>\n\n\n<p>\u65b0\u5f0f\u7c7b\u90fd\u7ee7\u627fobject\uff0c\u65e7\u5f0f\u7c7b\u4e0d\u9700\u8981\u3002\u65b0\u5f0f\u7c7b\u7684MRO\u91c7\u7528\u5e7f\u5ea6\u4f18\u5148\u641c\u7d22\uff0c\u800c\u65e7\u5f0f\u7c7b\u91c7\u7528\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\u3002<\/p>\n\n\n<p>\u65e7\u5f0f\u7c7b\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>class A:\n\tpass\nclass B:\n\tpass\nclass C(B):\n\tpass\nclass D(C,A):\n\tpass<\/code><\/pre>\n\n\n<p>\u6267\u884c\u987a\u5e8f\uff08\u6df1\u5ea6\u4f18\u5148\uff09\uff1aD-C-B-A<\/p>\n\n\n<p>\u65b0\u5f0f\u7c7b\uff1a<\/p>\n\n\n<pre class=\"wp-block-code\"><code>class A(object):\n\tpass\nclass B(object):\n\tpass\nclass C(object):\n\tpass\nclass D(A,B,C):\n\tpass<\/code><\/pre>\n\n\n<p>\u6267\u884c\u987a\u5e8f\uff08\u5e7f\u5ea6\u4f18\u5148\uff09\uff1aD-A-B-C-Object<\/p>\n\n\n<p>python2\u4e2d\u9ed8\u8ba4\u65e7\u5f0f\u7c7b\uff0c\u65b0\u5f0f\u7c7b\u8981\u663e\u5f0f\u58f0\u660e\u3002<\/p>\n\n\n<p>python3\u4e2d\u90fd\u662f\u65b0\u5f0f\u7c7b\uff0c\u65e7\u5f0f\u7c7b\u88ab\u79fb\u9664\u3002<\/p>\n\n\n<p><strong>117. dir()\u662f\u5e72\u4ec0\u4e48\u7528\u7684\uff1f <\/strong><\/p>\n\n\n<p>\u67e5\u770b\u5bf9\u8c61\u6709\u4ec0\u4e48\u65b9\u6cd5\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"351\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-157.png\" alt=\"\" class=\"wp-image-3343\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-157.png 1020w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-157-300x103.png 300w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-157-768x264.png 768w\" sizes=\"(max-width: 1020px) 100vw, 1020px\" \/><\/figure><\/div>\n\n\n<p><strong>118. \u4e00\u4e2a\u5305\u91cc\u6709\u4e09\u4e2a\u6a21\u5757\uff0cdemo1.py, demo2.py, demo3.py\uff0c\u4f46\u4f7f\u7528 from tools import *\u5bfc\u5165\u6a21\u5757\u65f6\uff0c\u5982\u4f55\u4fdd\u8bc1\u53ea\u6709 demo1\u3001demo3 \u88ab\u5bfc\u5165\u4e86\u3002 <\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><code>from tools import demo1\nfrom tools import demo2<\/code><\/pre>\n\n\n<p>\u6216\u8005\uff08\u4f46\u4e0d\u63a8\u8350\uff09<\/p>\n\n\n<pre class=\"wp-block-code\"><code>from tools import demo1,demo2<\/code><\/pre>\n\n\n<p><strong>119. \u5217\u4e3e 5 \u4e2a Python \u4e2d\u7684\u5f02\u5e38\u7c7b\u578b\u4ee5\u53ca\u5176\u542b\u4e49 <\/strong><\/p>\n\n\n<ul><li>IndexError \u7d22\u5f15\u8d8a\u754c<\/li><li>KeyError  \u6ca1\u6709\u8fd9\u4e2a\u5173\u952e\u5b57<\/li><li>NameError  \u53d8\u91cf\u4f7f\u7528\u524d\u672a\u5b9a\u4e49<\/li><li>IndentationError  \u7f29\u8fdb\u9519\u8bef<\/li><li>TypeError   \u7c7b\u578b\u9519\u8bef\uff0c\u6bd4\u5982int(&#8216;hahaa&#8217;)<\/li><li>ZeroDivsionError   \u96f6\u9664<\/li><li>\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7<\/li><\/ul>\n\n\n<p><strong>120. copy \u548c deepcopy \u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f <\/strong><\/p>\n\n\n<p>copy\u662f\u6d45\u62f7\u8d1d\uff0c\u800cdeepcopy\u662f\u6df1\u62f7\u8d1d\u3002<\/p>\n\n\n<p>\u6211\u4eec\u90fd\u77e5\u9053python\u7684\u5bf9\u8c61\u5206\u4e3a\u53ef\u53d8\u5bf9\u8c61\u548c\u4e0d\u53ef\u53d8\u5bf9\u8c61\uff0c\u56e0\u6b64\u4e3e\u4e2a\u4f8b\u5b50\u3002<\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"182\" height=\"218\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-159.png\" alt=\"\" class=\"wp-image-3345\"\/><\/figure><\/div>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"198\" height=\"207\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-158.png\" alt=\"\" class=\"wp-image-3344\"\/><\/figure><\/div>\n\n\n<p>\u601d\u8003\u4e0a\u9762\u4e24\u4e2a\u4f8b\u5b50\uff0c\u5176\u4e2d\u5bf9\u4e8e\u5217\u8868\u4e2d\u6709\u53ef\u53d8\u7c7b\u578b\u65f6\uff0c\u6df1\u62f7\u8d1d\u7684\u6d45\u62f7\u8d1d\u7684\u533a\u522b\u663e\u73b0\u4e86\u51fa\u6765\u3002<\/p>\n\n\n<p>\u56e0\u6b64\uff0c\u53ef\u4ee5\u7b80\u5355\u7684\u7406\u89e3\u4e3a\uff0c\u6d45\u62f7\u8d1d\u53ea\u62f7\u8d1d\u4e00\u5c42\u5730\u5740\uff0c\u800c\u6df1\u62f7\u8d1d\u4f1a\u7ee7\u7eed\u5411\u4e0b\u62f7\u8d1d\u5143\u7d20\u7684\u5b50\u5143\u7d20\u5730\u5740\u3002<\/p>\n\n\n<p><strong>121. \u4ee3\u7801\u4e2d\u7ecf\u5e38\u9047\u5230\u7684*args, **kwargs \u542b\u4e49\u53ca\u7528\u6cd5\u3002 <\/strong><\/p>\n\n\n<p>*args\u662f\u5143\u7ec4\u7c7b\u578b\uff0c**kwargs\u662f\u5b57\u5178\u7c7b\u578b\u3002<\/p>\n\n\n<pre class=\"wp-block-code\"><code>def function(arg,*args,**kwargs):\n    print(arg,args,kwargs)\nfunction(6,7,8,9,a=1, b=2, c=3)<\/code><\/pre>\n\n\n<p>  \u8f93\u51fa\uff1a6 (7, 8, 9) {&#8216;a&#8217;: 1, &#8216;b&#8217;: 2, &#8216;c&#8217;: 3} <\/p>\n\n\n<p><strong>122. Python \u4e2d\u4f1a\u6709\u51fd\u6570\u6216\u6210\u5458\u53d8\u91cf\u5305\u542b\u5355\u4e0b\u5212\u7ebf\u524d\u7f00\u548c\u7ed3\u5c3e\uff0c\u548c\u53cc\u4e0b\u5212\u7ebf\u524d\u7f00\u7ed3\u5c3e\uff0c\u533a\u522b\u662f\u4ec0\u4e48? <\/strong><\/p>\n\n\n<ul><li>_xxx \u4e0d\u80fd\u7528\u4e8e\u2019from module import *\u2019 \u4ee5\u5355\u4e0b\u5212\u7ebf\u5f00\u5934\u7684\u8868\u793a\u7684\u662fprotected\u7c7b\u578b\u7684\u53d8\u91cf\u3002\u5373\u4fdd\u62a4\u7c7b\u578b\u53ea\u80fd\u5141\u8bb8\u5176\u672c\u8eab\u4e0e\u5b50\u7c7b\u8fdb\u884c\u8bbf\u95ee\u3002<\/li><li>__xxx \u53cc\u4e0b\u5212\u7ebf\u7684\u8868\u793a\u7684\u662f\u79c1\u6709\u7c7b\u578b\u7684\u53d8\u91cf\u3002\u53ea\u80fd\u662f\u5141\u8bb8\u8fd9\u4e2a\u7c7b\u672c\u8eab\u8fdb\u884c\u8bbf\u95ee\u4e86\u3002\u8fde\u5b50\u7c7b\u4e5f\u4e0d\u53ef\u4ee5<\/li><li>__xxx___ \u5b9a\u4e49\u7684\u662f\u7279\u5217\u65b9\u6cd5\u3002\u50cf__init__\u4e4b\u7c7b\u7684<\/li><\/ul>\n\n\n<p><strong>123. w\u3001a+\u3001wb \u6587\u4ef6\u5199\u5165\u6a21\u5f0f\u7684\u533a\u522b <\/strong><\/p>\n\n\n<p>w\uff1a\u53ea\u5199<\/p>\n\n\n<p>a+\uff1a\u53ef\u8bfb\u53ef\u5199\uff0c\u6ca1\u6709\u521b\u5efa<\/p>\n\n\n<p>wb\uff1a\u4e8c\u8fdb\u5236\u5199<\/p>\n\n\n<p><strong>124. \u4e3e\u4f8b sort \u548c sorted \u7684\u533a\u522b <\/strong><\/p>\n\n\n<p> sort\u662flist\u7684\u4e00\u4e2a\u5c5e\u6027\u65b9\u6cd5\uff0c\u6539\u53d8\u539f\u5217\u8868\u3002<br \/> sorted\u4e0d\u6539\u53d8\u539f\u5217\u8868\uff0c\u751f\u6210\u65b0\u5217\u8868\u3002 <\/p>\n\n\n<p><strong>125. \u4ec0\u4e48\u662f\u8d1f\u7d22\u5f15\uff1f <\/strong><\/p>\n\n\n<p>\u5012\u662f\u7b2c\u7edd\u5bf9\u503c\u4e2a\u6570\u3002<\/p>\n\n\n<p><strong>126. pprint \u6a21\u5757\u662f\u5e72\u4ec0\u4e48\u7684\uff1f <\/strong><\/p>\n\n\n<p>print()\u548cpprint()\u90fd\u662fpython\u7684\u6253\u5370\u6a21\u5757\uff0c\u529f\u80fd\u57fa\u672c\u4e00\u6837\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u662fpprint()\u6a21\u5757\u6253\u5370\u51fa\u6765\u7684\u6570\u636e\u7ed3\u6784\u66f4\u52a0\u5b8c\u6574\uff0c\u6bcf\u884c\u4e3a\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\uff0c\u66f4\u52a0\u65b9\u4fbf\u9605\u8bfb\u6253\u5370\u8f93\u51fa\u7ed3\u679c\u3002\u7279\u522b\u662f\u5bf9\u4e8e\u7279\u522b\u957f\u7684\u6570\u636e\u6253\u5370\uff0cprint()\u8f93\u51fa\u7ed3\u679c\u90fd\u5728\u4e00\u884c\uff0c\u4e0d\u65b9\u4fbf\u67e5\u770b\uff0c\u800cpprint()\u91c7\u7528\u5206\u884c\u6253\u5370\u8f93\u51fa\uff0c\u6240\u4ee5\u5bf9\u4e8e\u6570\u636e\u7ed3\u6784\u6bd4\u8f83\u590d\u6742\u3001\u6570\u636e\u957f\u5ea6\u8f83\u957f\u7684\u6570\u636e\uff0c\u9002\u5408\u91c7\u7528pprint()\u6253\u5370\u65b9\u5f0f\u3002\u5f53\u7136\uff0c\u4e00\u822c\u60c5\u51b5\u591a\u6570\u91c7\u7528print()\u3002 <\/p>\n\n\n<p><strong>127. \u89e3\u91ca\u4e00\u4e0b Python \u4e2d\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26 <\/strong><\/p>\n\n\n<p>+\u3001-\u3001*\u3001\/\u3001+=\u3001-=\u3001*=\u3001\/=<\/p>\n\n\n<p><strong>128. \u89e3\u91ca\u4e00\u4e0b Python \u4e2d\u7684\u903b\u8f91\u8fd0\u7b97\u7b26 <\/strong><\/p>\n\n\n<p>and or not is <\/p>\n\n\n<p><strong>129. \u8bb2\u8bb2 Python \u4e2d\u7684\u4f4d\u8fd0\u7b97\u7b26 <\/strong><\/p>\n\n\n<p>&amp;\u6309\u4f4d\u4e0e\u3001|\u6309\u4f4d\u6216\u3001^\u5f02\u6216\u3001~\u53d6\u53cd\u3001&lt;&lt;\u5de6\u79fb\u3001&gt;&gt;\u53f3\u79fb\u3002<\/p>\n\n\n<p><strong>130. \u5728 Python \u4e2d\u5982\u4f55\u4f7f\u7528\u591a\u8fdb\u5236\u6570\u5b57\uff1f <\/strong><\/p>\n\n\n<p>int()\u5341\u8fdb\u5236\u3001bin()\u4e8c\u8fdb\u5236\u3001oct()\u516b\u8fdb\u5236\u3001hex()\u5341\u516d\u8fdb\u5236\u3002<\/p>\n\n\n<p><strong>131. \u600e\u6837\u58f0\u660e\u591a\u4e2a\u53d8\u91cf\u5e76\u8d4b\u503c\uff1f <\/strong><\/p>\n\n\n<p>a,b = 1,2<\/p>\n\n\n<p><strong>132. \u5df2\u77e5\uff1a <\/strong><\/p>\n\n\n<ul><li><strong> \u4ece AList \u548c BSet \u4e2d \u67e5\u627e 4\uff0c\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u90a3\u4e2a\u5927\uff1f <\/strong><\/li><li><strong> \u4ece AList \u548c BSet \u4e2d \u63d2\u5165 4\uff0c\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u90a3\u4e2a\u5927\uff1f <\/strong><\/li><\/ul>\n\n\n<p>list\u7684\u540e\u53f0\u5b9e\u73b0\u662f\u5217\u8868\uff0c\u91c7\u7528\u7ebf\u6027\u67e5\u627e\uff0c\u56e0\u6b64\u65f6\u95f4\u590d\u6742\u5ea6\u4e3an\uff1b\u76f4\u63a5\u63d2\u5165\uff0c\u65f6\u95f4\u590d\u6742\u5ea61\u3002<\/p>\n\n\n<p>set\u7684\u540e\u53f0\u5b9e\u73b0\u662f\u5b57\u5178\uff0c\u91c7\u7528\u4e8c\u53c9\u6811\u6392\u5e8f\uff0c\u65f6\u95f4\u590d\u6742\u5ea6lgn\uff0c\u5efa\u6811\u63d2\u5165\uff0c\u65f6\u95f4\u590d\u6742\u5ea6lgn\u3002<\/p>\n\n\n<p><strong>133. \u7528 Python \u5b9e\u73b0\u4e00\u4e2a\u4e8c\u5206\u67e5\u627e\u7684\u51fd\u6570 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"334\" height=\"266\" src=\"\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-175.png\" alt=\"\" class=\"wp-image-3379\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-175.png 334w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/03\/\u56fe\u7247-175-300x239.png 300w\" sizes=\"(max-width: 334px) 100vw, 334px\" \/><\/figure><\/div>\n\n\n<p><strong>134. python \u5355\u4f8b\u6a21\u5f0f\u7684\u5b9e\u73b0\u65b9\u6cd5 <\/strong><\/p>\n\n\n<p>python\u5929\u7136\u5c31\u662f\u5355\u4f8b\u6a21\u5f0f\uff0c\u56e0\u6b64\u53ea\u9700\u8981\u5728\u7c7b\u4e2d\u65b0\u5efa\u81ea\u5df1\u7684\u5bf9\u8c61\u5373\u53ef\u3002\u66f4\u591a\u5355\u4f8b\u6a21\u5f0f\u65b9\u6cd5\u611f\u5174\u8da3\u7684\u81ea\u5df1\u67e5\u3002<\/p>\n\n\n<p><strong>135. \u4f7f\u7528 Python \u5b9e\u73b0\u4e00\u4e2a\u6590\u6ce2\u90a3\u5951\u6570\u5217 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"274\" height=\"117\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247.png\" alt=\"\" class=\"wp-image-3422\"\/><\/figure><\/div>\n\n\n<p><strong>136. \u627e\u51fa\u5217\u8868\u4e2d\u7684\u91cd\u590d\u6570\u5b57 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"217\" height=\"123\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-1.png\" alt=\"\" class=\"wp-image-3423\"\/><\/figure><\/div>\n\n\n<p><strong>137. \u627e\u51fa\u5217\u8868\u4e2d\u7684\u5355\u4e2a\u6570\u5b57 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"229\" height=\"164\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-2.png\" alt=\"\" class=\"wp-image-3424\"\/><\/figure><\/div>\n\n\n<p><strong>138. \u5199\u4e00\u4e2a\u5192\u6ce1\u6392\u5e8f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"147\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-3.png\" alt=\"\" class=\"wp-image-3425\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-3.png 381w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-3-300x116.png 300w\" sizes=\"(max-width: 381px) 100vw, 381px\" \/><\/figure><\/div>\n\n\n<p><strong>139. \u5199\u4e00\u4e2a\u5feb\u901f\u6392\u5e8f <\/strong><\/p>\n\n\n<p>\u8be6\u89c1\uff1a<a rel=\"noreferrer noopener\" aria-label=\"\u3010\u7b97\u6cd5\u5bfc\u8bba\u3011\u5feb\u901f\u6392\u5e8f\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"http:\/\/www.sniper97.cn\/index.php\/note\/introduction_to_algorithms\/2277\/\" target=\"_blank\">\u3010\u7b97\u6cd5\u5bfc\u8bba\u3011\u5feb\u901f\u6392\u5e8f<\/a><\/p>\n\n\n<p><strong>140. \u5199\u4e00\u4e2a\u62d3\u6251\u6392\u5e8f <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"442\" height=\"776\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-4.png\" alt=\"\" class=\"wp-image-3426\" srcset=\"http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-4.png 442w, http:\/\/www.sniper97.cn\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-4-171x300.png 171w\" sizes=\"(max-width: 442px) 100vw, 442px\" \/><\/figure><\/div>\n\n\n<p><strong>141. python \u5b9e\u73b0\u4e00\u4e2a\u4e8c\u8fdb\u5236\u8ba1\u7b97 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"273\" height=\"99\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-5.png\" alt=\"\" class=\"wp-image-3427\"\/><\/figure><\/div>\n\n\n<p><strong>142. \u6709\u4e00\u7ec4\u201c+\u201d\u548c\u201c-\u201d\u7b26\u53f7\uff0c\u8981\u6c42\u5c06\u201c+\u201d\u6392\u5230\u5de6\u8fb9\uff0c\u201c-\u201d\u6392\u5230\u53f3\u8fb9\uff0c\u5199\u51fa\u5177\u4f53\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002 <\/strong><\/p>\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"216\" height=\"182\" src=\"\/wp-content\/uploads\/2020\/04\/\u56fe\u7247-6.png\" alt=\"\" class=\"wp-image-3428\"\/><\/figure><\/div>\n\n\n<p><strong>143. \u5355\u94fe\u8868\u53cd\u8f6c <\/strong><\/p>\n\n\n<p>\u7565<\/p>\n\n\n<p><strong>144. \u4ea4\u53c9\u94fe\u8868\u6c42\u4ea4\u70b9 <\/strong><\/p>\n\n\n<p>\n\u7565\n<\/p>\n\n\n<p><strong>145. \u7528\u961f\u5217\u5b9e\u73b0\u6808 <\/strong><\/p>\n\n\n<p>\n\u7565\n<\/p>\n\n\n<p><strong>146. \u627e\u51fa\u6570\u636e\u6d41\u7684\u4e2d\u4f4d\u6570 <\/strong><\/p>\n\n\n<p>\n\u7565\n<\/p>\n\n\n<p><strong>147. \u4e8c\u53c9\u641c\u7d22\u6811\u4e2d\u7b2c K \u5c0f\u7684\u5143\u7d20 <\/strong><\/p>\n\n\n<p> \u7565 <\/p>\n\n\n<p><strong>148. \u5728 requests \u6a21\u5757\u4e2d\uff0crequests.content \u548c requests.text \u4ec0\u4e48\u533a\u522b<\/strong><\/p>\n\n\n<p>\u5927\u90e8\u5206\u60c5\u51b5\u662f\u6ca1\u6709\u533a\u522b\u7684\uff0c\u5176\u4e2d\uff1acontent\u8fd4\u56de\u7684\u662f\u5b57\u8282\u7801\uff0c\u800ctext\u662f\u7f16\u7801\u540e\u7684\u6587\u672c\uff08\u731c\u6d4b\u7f16\u7801\uff09\uff0c\u56e0\u6b64\u5728text\u731c\u9519\u7684\u60c5\u51b5\u4e0b\u9700\u8981\u6211\u4eec\u4f7f\u7528content.decode()\u6765\u8fdb\u884c\u91cd\u65b0\u89e3\u7801\u3002<\/p>\n\n\n<p><strong>149. \u7b80\u8981\u5199\u4e00\u4e0b lxml \u6a21\u5757\u7684\u4f7f\u7528\u65b9\u6cd5\u6846\u67b6 <\/strong><\/p>\n\n\n<p>\u8be6\u89c1\uff1a<a rel=\"noreferrer noopener\" aria-label=\"\u7f51\u7edc\u722c\u866b \u89e3\u6790\u5e93\u7684\u4f7f\u7528\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"http:\/\/www.sniper97.cn\/index.php\/note\/carwler\/1000\/\" target=\"_blank\">\u7f51\u7edc\u722c\u866b \u89e3\u6790\u5e93\u7684\u4f7f\u7528<\/a><\/p>\n\n\n<p><strong>150. \u8bf4\u4e00\u8bf4 scrapy \u7684\u5de5\u4f5c\u6d41\u7a0b <\/strong><\/p>\n\n\n<p>\u9996\u5148Spiders\u5c06\u9700\u8981\u8bf7\u6c42\u7684url\u7ecfScrapyEngine\u4ea4\u7ed9Scheduler\u3002<\/p>\n\n\n<p>Scheduler\u5904\u7406\u540e\uff0c\u7ecfScrapyEngine\uff0cDownloaderMiddlewares\u4ea4\u7ed9Downloader\u3002<\/p>\n\n\n<p>Downloader\u5411\u7f51\u7ad9\u8fdb\u884c\u8bf7\u6c42\uff0c\u63a5\u53d7\u54cd\u5e94\uff0c\u5c06response\u7ecf\u8fc7ScrapyEngine\uff0cSpiderMiddleware\u4ea4\u7ed9Spiders\u3002<\/p>\n\n\n<p>spiders\u5904\u7406response\uff0c\u63d0\u53d6\u6570\u636e\uff0c\u7ecf\u8fc7ScrapyEngine\u4ea4\u7ed9ItemPipline\u8fdb\u884c\u672c\u5730\uff08\u6570\u636e\u5e93\uff09\u4fdd\u5b58\u3002<\/p>\n\n\n<p><strong>151. scrapy \u7684\u53bb\u91cd\u539f\u7406 <\/strong><\/p>\n\n\n<p>Scrapy\u672c\u8eab\u5e26\u6709\u4e00\u4e2a\u4e2d\u95f4\u4ef6\u8fdb\u884c\u53bb\u91cd\uff0c\u53ef\u4ee5\u5728scrapy\u7684\u6e90\u7801\u4e2d\u627e\u5230\u4e00\u4e2a dupefilters.py \u6587\u4ef6\uff0c\u540c\u65f6\u53c8\u4e00\u4e2adont_fliter\u5f00\u5173\u8fdb\u884c\u63a7\u5236\u662f\u5426\u8fdb\u884c\u53bb\u91cd\u64cd\u4f5c\u3002<\/p>\n\n\n<p>\u5bf9\u4e8e\u6bcf\u4e00\u4e2aurl\uff0c\u6839\u636eurl\uff08\u5904\u7406\uff09\u4f7f\u7528set\u8fdb\u884c\u53bb\u91cd\u3002<\/p>\n\n\n<p><strong>152. scrapy \u4e2d\u95f4\u4ef6\u6709\u51e0\u79cd\u7c7b\uff0c\u4f60\u7528\u8fc7\u54ea\u4e9b\u4e2d\u95f4\u4ef6 <\/strong><\/p>\n\n\n<p>Doenloader Middleware\u7b49\u3002<\/p>\n\n\n<p><strong>153. \u4f60\u5199\u722c\u866b\u7684\u65f6\u5019\u90fd\u9047\u5230\u8fc7\u4ec0\u4e48\uff1f\u53cd\u722c\u866b\u63aa\u65bd\uff0c\u4f60\u662f\u600e\u4e48\u89e3\u51b3\u7684\uff1f<\/strong> <\/p>\n\n\n<p>\u6bd4\u8f83\u7b80\u5355\u7684\u5c31\u662f\u5404\u79cd.gov\u3001.edu\u3001\u8fd9\u7c7b\u7f51\u7ad9\u7684\u53cd\u722c\uff0c\u51e0\u4e4e\u6ca1\u6709\uff0c\u7b80\u5355\u7684requests\u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n<p>\u5176\u6b21\u5c31\u662f\u6bd4\u5982\u5fae\u535a\u3001\u77e5\u4e4e\u3001CSDN\u8fd9\u79cd\u672c\u8eab\u5c31\u6709\u5927\u91cf\u533f\u540d\u8bbf\u95ee\u6d41\u91cf\u7684\u516c\u5f00\u7f51\u7ad9\u3002\u8fd9\u79cd\u7f51\u7ad9\u4e00\u822c\u4f1a\u5728ip\u8bbf\u95ee\u9891\u7387\u548c\u767b\u5f55\u72b6\u6001\u4e0a\u8fdb\u884c\u9650\u5236\uff0c\u8fd9\u79cd\u53ea\u8981\u52a0\u4e00\u4e2aip\u4ee3\u7406\u6216\u8005\u63a7\u5236\u8bbf\u95ee\u9891\u7387\u548c\u643a\u5e26cookie\u5373\u53ef\u3002<\/p>\n\n\n<p>\u518d\u5c31\u662f\u4f8b\u5982\u6dd8\u5b9d\u8fd9\u7c7b\u7f51\u7ad9\u53ef\u80fd\u6709\u52a0\u5bc6\u63a5\u53e3\uff0c\u6ca1\u6709\u529e\u6cd5\u76f4\u63a5\u627e\u5230\u63a5\u53e3\uff0c\u4e00\u822c\u4f7f\u7528js\u89e3\u5bc6\u6216\u8005\u4f7f\u7528\u6d4b\u8bd5\u6846\u67b6\u3002\u5305\u62ecselenium\u7b49\u3002<\/p>\n\n\n<p>\u518d\u9ad8\u7684\u6bd4\u5982\u6dd8\u5b9d\uff0c\u67d0\u4e9b\u9875\u9762\u6709\u56fe\u5c42\u906e\u6321\u3001\u751a\u81f3\u6709\u6d4b\u8bd5\u6846\u67b6\u68c0\u6d4b\uff0c\u9664\u4e86\u5e94\u7528\u5c0f\u4f17\u6d4b\u8bd5\u6846\u67b6\u4ee5\u5916\u6c34\u5e73\u6709\u9650\uff0c\u4e0d\u77e5\u9053\u600e\u4e48\u89e3\u51b3\u3002<\/p>\n\n\n<p><strong>154. \u4e3a\u4ec0\u4e48\u4f1a\u7528\u5230\u4ee3\u7406\uff1f <\/strong><\/p>\n\n\n<p>\u7531\u4e8e\u8bbf\u95ee\u8fc5\u901f\u76ee\u6807\u7f51\u7ad9\u62d2\u7edd\u8bbf\u95ee\u65f6\uff0c\u9700\u8981\u4f7f\u7528\u5927\u91cf\u5176\u4ed6ip\u4f5c\u4e3a\u4ee3\u7406\u8bbf\u95ee\u76ee\u6807\u7f51\u7ad9\u3002<\/p>\n\n\n<p><strong>155. \u4ee3\u7406\u5931\u6548\u4e86\u600e\u4e48\u5904\u7406\uff1f <\/strong><\/p>\n\n\n<p>\u7ef4\u6301\u4ee3\u7406\u6c60\uff0c\u5fc3\u8df3\u68c0\u6d4b\u4ee3\u7406\u53ef\u7528\u6027\u3002<\/p>\n\n\n<p><strong> 156.\u5217\u51fa\u4f60\u77e5\u9053 header \u7684\u5185\u5bb9\u4ee5\u53ca\u4fe1\u606f <\/strong><\/p>\n\n\n<ul><li>Accept\uff1a\u63a5\u53d7\u8fd4\u56de\u6587\u4ef6\u7231\u4f60\u7c7b\u578b<\/li><li>Accept-Encoding:\u63a5\u53d7\u8fd4\u56de\u7f16\u7801<\/li><li>Accept-Language\uff1a\u63a5\u53d7\u8fd4\u56de\u8bed\u8a00<\/li><li>Connection\uff1a\u662f\u5426\u6301\u7eed\u8fde\u63a5\uff08HTTP1.0\/1.1\uff09<\/li><li>Cookie\uff1a\u4fdd\u5b58\u767b\u5f55\u72b6\u6001\uff0c\u5728\u4eac\u4e1c\u7b49\u7f51\u7ad9\u4e5f\u7528\u6765\u4fdd\u5b58\u8d2d\u7269\u8f66\u4fe1\u606f<\/li><li>Host\uff1a\u76ee\u6807\u4e3b\u673a<\/li><li>Referer\uff1a\u6765\u6e90\uff08\u6bd4\u5982\u4ece\u767e\u5ea6\u70b9\u5165\u67d0\u9875\uff0creferer\u5c31\u662f\u767e\u5ea6\uff09<\/li><li>User-Agent\uff1a\u6d4f\u89c8\u5668\u76f8\u5173\u4fe1\u606f<\/li><\/ul>\n\n\n<p><strong>157. \u8bf4\u4e00\u8bf4\u6253\u5f00\u6d4f\u89c8\u5668\u8bbf\u95ee \u767e\u5ea6\u4e00\u4e0b\uff0c\u4f60\u5c31\u77e5\u9053 \u83b7\u53d6\u5230\u7ed3\u679c\uff0c\u6574\u4e2a\u6d41\u7a0b\u3002 <\/strong><\/p>\n\n\n<p>\u8fd9\u91cc\u662f\u8003\u4e09\u6b21\u63e1\u624b\u5417\uff1f\u9996\u5148\u6d4f\u89c8\u5668\u5411\u670d\u52a1\u5668\u53d1\u9001\u8be2\u95ee\u8bf7\u6c42\uff0c\u7136\u540e\u670d\u52a1\u5668\u8fd4\u56deACK\uff0c\u7136\u540e\u6d4f\u89c8\u5668\u8fd4\u56deACK\u7684ACK\u3002\u7136\u540e\u5c06\u767e\u5ea6\u7684\u4e3b\u9875\u53d1\u9001\u5230\u6d4f\u89c8\u5668\uff0c\u89e3\u6790\u7ed9\u7528\u6237\u3002<\/p>\n\n\n<p>\u5982\u679c\u4f7f\u7528HTTP1.1\uff0c\u5f53\u4f60\u70b9\u51fb\u641c\u7d22\u65f6\uff0c\u5411\u670d\u52a1\u5668\u53d1\u9001\u8bf7\u6c42\u5e76\u83b7\u53d6\u7ed3\u679c\u3002\uff08\u767e\u5ea6\u786e\u5b9e\u4f7f\u7528HTTP1.1\uff09\u3002<\/p>\n\n\n<p>\u5982\u679c\u662fHTTP1.0\uff0c\u5219\u91cd\u590d\u4e0a\u8ff0\u63e1\u624b\u8fc7\u7a0b\u3002<\/p>\n\n\n<p><strong>158. \u722c\u53d6\u901f\u5ea6\u8fc7\u5feb\u51fa\u73b0\u4e86\u9a8c\u8bc1\u7801\u600e\u4e48\u5904\u7406 <\/strong><\/p>\n\n\n<p>\u964d\u901f\uff0c\u6216\u8005\u5904\u7406\u9a8c\u8bc1\u7801\uff0c\u4e0d\u8fc7\u73b0\u5728\u5f88\u591a\u516c\u53f8\u90fd\u63a5\u5165\u6781\u9a8c\u4e86\uff0c\u8fd8\u662f\u964d\u901f\u6216\u8005\u4f7f\u7528\u4ee3\u7406\u6bd4\u8f83\u7a33\u59a5\u3002<\/p>\n\n\n<p><strong>159. scrapy \u548c scrapy-redis \u6709\u4ec0\u4e48\u533a\u522b\uff1f\u4e3a\u4ec0\u4e48\u9009\u62e9 redis \u6570\u636e\u5e93\uff1f <\/strong><\/p>\n\n\n<p>scrapy\u662f\u722c\u866b\u6846\u67b6\uff0c\u800cscrapy\u662fredis\u5bf9scrapy\u7684\u652f\u6301\u7ec4\u4ef6\u3002<\/p>\n\n\n<p>redis\u4e3a\u5185\u5b58\u6570\u636e\u5e93\uff0c\u5177\u6709\u5f88\u5feb\u7684\u8bfb\u5199\u6548\u7387\u3002<\/p>\n\n\n<p><strong>160. \u5206\u5e03\u5f0f\u722c\u866b\u4e3b\u8981\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898 <\/strong><\/p>\n\n\n<p>\u76ee\u6807\u670d\u52a1\u5668\u5bf9ip\u7684\u9650\u5236\u4ee5\u53ca\u9ad8\u901f\u7387\u8981\u6c42\u7684\u722c\u53d6\u3002<\/p>\n\n\n<p><strong>161. \u5199\u722c\u866b\u662f\u7528\u591a\u8fdb\u7a0b\u597d\uff1f\u8fd8\u662f\u591a\u7ebf\u7a0b\u597d\uff1f \u4e3a\u4ec0\u4e48\uff1f <\/strong><\/p>\n\n\n<p>\u591a\u7ebf\u7a0b\u597d\uff0c\u56e0\u4e3a\u722c\u866b\u5c5e\u4e8eIO\u5bc6\u96c6\u578b\u3002<\/p>\n\n\n<p><strong>162. \u89e3\u6790\u7f51\u9875\u7684\u89e3\u6790\u5668\u4f7f\u7528\u6700\u591a\u7684\u662f\u54ea\u51e0\u4e2a <\/strong><\/p>\n\n\n<p>beautifulsoup\u3001lxml<\/p>\n\n\n<p><strong>163. \u9700\u8981\u767b\u5f55\u7684\u7f51\u9875\uff0c\u5982\u4f55\u89e3\u51b3\u540c\u65f6\u9650\u5236 ip\uff0ccookie,session\uff08\u5176\u4e2d\u6709\u4e00\u4e9b\u662f\u52a8\u6001\u751f\u6210\u7684\uff09\u5728\u4e0d\u4f7f\u7528\u52a8\u6001\u722c\u53d6\u7684\u60c5\u51b5\u4e0b\uff1f <\/strong><\/p>\n\n\n<p>\u4ee3\u7406\u6c60+js\u9006\u5411\u3002<\/p>\n\n\n<p><strong>164. \u9a8c\u8bc1\u7801\u7684\u89e3\u51b3\uff08\u7b80\u5355\u7684\uff1a\u5bf9\u56fe\u50cf\u505a\u5904\u7406\u540e\u53ef\u4ee5\u5f97\u5230\u7684\uff0c\u56f0\u96be\u7684\uff1a\u9a8c\u8bc1\u7801\u662f\u70b9\u51fb\uff0c\u62d6\u52a8\u7b49\u52a8\u6001\u8fdb\u884c\u7684\uff1f\uff09 <\/strong><\/p>\n\n\n<p>selenium\u6709js\u65b9\u6cd5\u53ef\u4ee5\u8fdb\u884c\u62d6\u52a8\u3002\u56fe\u7247\u76f4\u63a5OCR\u6216\u8005\u7c7b\u4f3c\u5904\u7406\u540e\u8f93\u5165\u5373\u53ef\u3002<\/p>\n\n\n<p><strong>165. \u4f7f\u7528\u6700\u591a\u7684\u6570\u636e\u5e93\uff08mysql\uff0cmongodb\uff0credis \u7b49\uff09\uff0c\u5bf9\u4ed6\u7684\u7406\u89e3\uff1f<\/strong> <\/p>\n\n\n<p>mysql\u4f20\u7edf\u6570\u636e\u5e93\uff0c\u5173\u7cfb\u578b\u3002mongodb\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0c\u652f\u6301\u5b57\u6bb5\u66f4\u591a\uff0c\u7531\u4e8e\u4f7f\u7528\u4e86\u5185\u5b58\u4f18\u5316\u4e5f\u5e76\u4e0d\u6162\uff08\u76f8\u6bd4mysql\uff09\u3002redis\u5185\u5b58\u6570\u636e\u5e93\uff0c\u8bfb\u53d6\u975e\u5e38\u5feb\uff0c\u4f46\u662f\u6ca1\u529e\u6cd5\u6c38\u4e45\u5b58\u50a8\u3002<\/p>\n\n\n<p><strong>166. TCP \u548c UDP \u7684\u533a\u522b\uff1f <\/strong><\/p>\n\n\n<ul><li>TCP\u9762\u5411\u8fde\u63a5\uff0cUDP\u65e0\u8fde\u63a5\u3002<\/li><li>TCP\u9762\u5411\u5b57\u8282\u6d41\uff0cUDP\u9762\u5411\u6570\u636e\u62a5\u3002<\/li><li>TCP\u4fdd\u8bc1\u6570\u636e\u6b63\u786e\uff0cUDP\u4e0d\u4fdd\u8bc1\u3002<\/li><li>TCP\u4fdd\u8bc1\u6570\u636e\u987a\u5e8f\uff0cUDP\u4e0d\u4fdd\u8bc1\u3002<\/li><\/ul>\n\n\n<p><strong>167. \u7b80\u8981\u4ecb\u7ecd\u4e09\u6b21\u63e1\u624b\u548c\u56db\u6b21\u6325\u624b <\/strong><\/p>\n\n\n<p>\u4e09\u6b21\u63e1\u624b\uff1a<\/p>\n\n\n<p>\u5ba2\u6237\u7aef\uff1a\u4f60\u597d\u3002<\/p>\n\n\n<p>\u670d\u52a1\u5668\uff1a\u6211\u6536\u5230\u4f60\u597d\u4e86\uff0c\u4f60\u597d\u3002<\/p>\n\n\n<p>\u5ba2\u6237\u7aef\uff1a\u6211\u6536\u5230\u4f60\u7684\u4f60\u597d\u4e86\uff0c\u641e\u8d77\u3002<\/p>\n\n\n<p>\u56db\u6b21\u6325\u624b\uff1a<\/p>\n\n\n<p>\u5ba2\u6237\u7aef\uff1a88<\/p>\n\n\n<p>\u670d\u52a1\u5668\uff1a\u6536\u5230<\/p>\n\n\n<p>\u670d\u52a1\u5668\uff1a88<\/p>\n\n\n<p>\u5ba2\u6237\u7aef\uff1a\u6536\u5230<\/p>\n\n\n<p><strong>168. \u4ec0\u4e48\u662f\u7c98\u5305\uff1f socket \u4e2d\u9020\u6210\u7c98\u5305\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f \u54ea\u4e9b\u60c5\u51b5\u4f1a\u53d1\u751f\u7c98\u5305\u73b0\u8c61\uff1f <\/strong><\/p>\n\n\n<p>\u6cbe\u5305\u5c31\u662f\u591a\u4e2a\u6570\u636e\u5305\u88ab\u8fde\u7eed\u9001\u5165\u63a5\u6536\u65b9\u7684\u7f13\u5b58\u4e2d\uff0c\u65e0\u6cd5\u5224\u65ad\u51fa\u6570\u636e\u8fb9\u754c\u3002<\/p>\n\n\n<p>\u9020\u6210\u6cbe\u5305\u7684\u539f\u56e0\u6709\u5f88\u591a\uff0c\u5728\u53d1\u9001\u65b9\u53ef\u80fd\u662f\u56e0\u4e3aTCP\u534f\u8bae\u672c\u8eab\u7684\u9650\u5236\uff0c\u5c06\u5f88\u591a\u5c0f\u5305\u6253\u6210\u5927\u5305\u540e\u53d1\u9001\uff0c\u56e0\u6b64\u53ef\u80fd\u9020\u6210\u6cbe\u5305\u3002<\/p>\n\n\n<p>\u5bf9\u4e8e\u63a5\u6536\u65b9\uff0c\u53ef\u80fd\u662f\u8fdb\u7a0b\u63a5\u53d7\u6570\u636e\u4e0d\u53ca\u65f6\uff0c\u5bfc\u81f4\u7f13\u5b58\u4e2d\u6ede\u7559\u8fc7\u591a\u6570\u636e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5217\u51fa 5 \u4e2a\u5e38\u7528 Python \u6807\u51c6\u5e93\uff1f \u5f88\u591a\uff0cos\u3001time\u3001random\u3001re\u3001math\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[24],"tags":[],"views":16063,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3135"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=3135"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/3135\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=3135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=3135"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=3135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}