{"id":1697,"date":"2021-08-02T15:15:57","date_gmt":"2021-08-02T07:15:57","guid":{"rendered":"https:\/\/egonlin.com\/?p=1697"},"modified":"2022-02-07T17:49:03","modified_gmt":"2022-02-07T09:49:03","slug":"%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=1697","title":{"rendered":"\u6a21\u5757"},"content":{"rendered":"<h1>\u6a21\u5757<\/h1>\n<h5>1.\u5217\u4e3e\u5e38\u7528\u7684\u6a21\u5757\u3002<\/h5>\n<pre><code class=\"language-python\">\u57fa\u7840\uff1a\nos,sys,time,datetime,json,pickle,randon,hashlib,re,math,logging\n\u722c\u866b\uff1a\nrequests,BeautifulSoup,xpath,gevent,asyncio,twisted\n\u6570\u636e\u5206\u6790\uff1a\npandas,numpy,scipy,matplotlib,seaborn\n\n\u7b49\u3002\u3002\u3002<\/code><\/pre>\n<h5>2.\u5982\u4f55\u5b89\u88c5\u7b2c\u4e09\u65b9\u6a21\u5757?<\/h5>\n<pre><code class=\"language-python\">pip3 install \u6a21\u5757\u540d\u79f0<\/code><\/pre>\n<h5>3.re \u7684 match \u548c search \u533a\u522b?<\/h5>\n<p>match()\u51fd\u6570\u53ea\u68c0\u6d4b\u5b57\u7b26\u4e32\u5f00\u5934\u4f4d\u7f6e\u662f\u5426\u5339\u914d\uff0c\u5339\u914d\u6210\u529f\u624d\u4f1a\u8fd4\u56de\u7ed3\u679c\uff0c\u5426\u5219\u8fd4\u56deNone<\/p>\n<pre><code class=\"language-python\">import re\n\ns1 = &#039;abcabcabc&#039;\n\nprint(re.match(&#039;abc&#039;, s1))\nprint(re.match(&#039;abc&#039;, s1).group())\nprint(re.match(&#039;abc&#039;, s1).span())<\/code><\/pre>\n<p>search()\u51fd\u6570\u4f1a\u5728\u6574\u4e2a\u5b57\u7b26\u4e32\u5185\u67e5\u627e\u6a21\u5f0f\u5339\u914d,\u53ea\u5230\u627e\u5230\u7b2c\u4e00\u4e2a\u5339\u914d\u7136\u540e\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5339\u914d\u4fe1\u606f\u7684\u5bf9\u8c61,\u8be5\u5bf9\u8c61\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528group()\u65b9\u6cd5\u5f97\u5230\u5339\u914d\u7684\u5b57\u7b26\u4e32,\u5982\u679c\u5b57\u7b26\u4e32\u6ca1\u6709\u5339\u914d\uff0c\u5219\u8fd4\u56deNone\u3002<\/p>\n<pre><code class=\"language-python\">import re\n\ns1 = &#039;abcabcabc&#039;\n\nprint(re.search(&#039;bca&#039;, s1))\nprint(re.search(&#039;bca&#039;, s1).group())\nprint(re.search(&#039;bca&#039;, s1).span())<\/code><\/pre>\n<h5>4.\u4ec0\u4e48\u662f\u6b63\u5219\u7684\u8d2a\u5a6a\u5339\u914d?\u6216 \u6b63\u5219\u5339\u914d\u4e2d\u7684\u8d2a\u5a6a\u6a21\u5f0f\u4e0e\u975e\u8d2a\u5a6a\u6a21\u5f0f\u7684\u533a\u522b?<\/h5>\n<p>\u8d2a\u5a6a\u6a21\u5f0f\uff1a\u80fd\u5339\u914d\u7684\u6700\u5927\u90e8\u5206<\/p>\n<p>\u201c.+\u201d\u4e2d\u7684+\u4f1a\u4e00\u76f4\u67e5\u627e\u5230\u6700\u540e\u4e00\u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u5b57\u7b26<\/p>\n<p>\u975e\u8d2a\u5a6a\u6a21\u5f0f\uff1a\u5339\u914d\u8d8a\u5c11\u8d8a\u597d<\/p>\n<p>\u201c.+?&quot;\u4f1a\u5339\u914d\u5230\u7b2c\u4e00\u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u5b57\u7b26\u5c31\u505c\u6b62<\/p>\n<h5>5.\u5982\u4f55\u751f\u6210\u4e00\u4e2a\u968f\u673a\u6570?<\/h5>\n<pre><code class=\"language-python\">import random\nrandom.randint(1,9)<\/code><\/pre>\n<h5>6.\u5982\u4f55\u4f7f\u7528 python \u5220\u9664\u4e00\u4e2a\u6587\u4ef6?<\/h5>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"1697\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"1697\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"5693c9f384\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"f48666364f\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>\u6a21\u5757 1.\u5217\u4e3e\u5e38\u7528\u7684\u6a21\u5757\u3002 \u57fa\u7840\uff1a os,sys,time,datetime,json,pickle,rand [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":2529,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[202],"tags":[216,217,215],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1697"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1697"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1697\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/media\/2529"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}