{"id":6484,"date":"2021-06-25T02:34:00","date_gmt":"2021-06-24T18:34:00","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=6484"},"modified":"2021-06-26T02:49:45","modified_gmt":"2021-06-25T18:49:45","slug":"%e4%bd%bf%e7%94%a8-python-%e4%bb%8e-0-%e5%bc%80%e5%8f%91%e5%b1%9e%e4%ba%8e%e4%bd%a0%e7%9a%84%e4%b8%aa%e4%ba%ba%e7%ae%a1%e7%90%86%e7%b3%bb%e7%bb%9f-16-%e7%af%87-%ef%bd%9c-%e8%ae%a1%e5%88%92%e6%95%b0","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=6484","title":{"rendered":"\u4f7f\u7528 Python \u4ece 0 \u5f00\u53d1\u5c5e\u4e8e\u4f60\u7684\u4e2a\u4eba\u7ba1\u7406\u7cfb\u7edf 16 \u7bc7 \uff5c \u8ba1\u5212\u6570\u636e\u7684\u83b7\u53d6\u4e0e\u5c55\u793a"},"content":{"rendered":"\n<p>\u73b0\u5728\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u4efb\u52a1\u521b\u5efa\u7684\u529f\u80fd\u4e86\uff0c\u63a5\u4e0b\u6765\u4f60\u5c31\u53ef\u4ee5\u5199\u83b7\u53d6\u6570\u636e\u7684\u63a5\u53e3\uff0c\u7136\u540e\u6e32\u67d3\u5230\u7f51\u9875\u4e2d\u53bb\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b9a\u4e49\u8def\u7531\u65b9\u6cd5\uff0c\u5728\u8fd9\u91cc\u6839\u636e\u4f20\u5165\u7684\u7528\u6237 id\uff0c\u5728\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u76f8\u5173\u7684\u4efb\u52a1\u5217\u8868\u6570\u636e\uff0c\u7136\u540e\u8fd4\u56de\u7ed9\u524d\u7aef\u9875\u9762\u3002<\/p>\n\n\n\n<h2>\u5982\u4f55\u83b7\u53d6\u4efb\u52a1\u5217\u8868\u6570\u636e\u5462\uff1f<\/h2>\n\n\n\n<p>\u4e0a\u6b21\u6211\u4eec\u5728\u5efa\u7acb\u6570\u636e\u6a21\u578b\u7684\u65f6\u5019\uff0c\u5df2\u7ecf\u5c06\u7528\u6237\u8868\u548c todo \u8868\u8fdb\u884c\u4e86\u5173\u8054\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">todos = db.relationship(&quot;Todo&quot;, backref='my_user')<\/pre><\/div>\n\n\n\n<p>\u90a3\u4e48\u73b0\u5728\u53ea\u8981\u901a\u8fc7\u6761\u4ef6\u67e5\u8be2\u5c31\u53ef\u4ee5\u83b7\u53d6\u8be5\u7528\u6237\u4e0b\u7684\u4efb\u52a1\u6570\u636e\u3002<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">\n\n@app.route('\/todolist\/', methods=['GET'])\ndef todolist():\n    user = User.query.filter_by(id=session['user_id']).first_or_404()\n<\/pre><\/div>\n\n\n\n<p>\u8fd9\u91cc\u901a\u8fc7\u7528\u6237 id \u67e5\u8be2\u7528\u6237\u6570\u636e\uff0c\u90a3\u4e48\u73b0\u5728\u8fd9\u4e2a user \u5bf9\u8c61\u7684 todos \u5c31\u662f\u8be5\u7528\u6237\u7684\u4efb\u52a1\u5217\u8868\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u5c06\u5f97\u5230\u7684 user \u4e0b\u7684\u4efb\u52a1\u8fd4\u56de\u7ed9 todolist.html:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">return render_template('todolist.html', form=todo_form, todolist=user.todos)<\/pre><\/div>\n\n\n\n<p>\u63a5\u7740\uff0c\u6211\u4eec\u5728 html \u5faa\u73af\u6e32\u67d3\u5217\u8868\u6570\u636e\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;wpum_restrict_type&quot;:&quot;wpum_restrict_type_state&quot;,&quot;wpum_hide_state_in&quot;:false,&quot;wpum_hide_state_out&quot;:false,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">\n\n {% for todo in todolist %}\n        &lt;!-- Earnings (Monthly) Card Example --&gt;\n        &lt;div class=&quot;col-xl-8 mx-auto mb-3&quot;&gt;\n            &lt;div class=&quot;card border-left-primary shadow h-100 py-2&quot;&gt;\n                &lt;div class=&quot;card-body&quot;&gt;\n                    &lt;div class=&quot;row no-gutters align-items-center&quot;&gt;\n                        &lt;div class=&quot;col&quot;&gt;\n                            &lt;div class=&quot;h5 mb-0 font-weight-bold text-gray-800&quot;&gt;{{ todo.description }}&lt;\/div&gt;\n                        &lt;\/div&gt;\n                        &lt;div class=&quot;col-auto&quot;&gt;\n                            &lt;input type=&quot;checkbox&quot; class=&quot;btn-check&quot; id=&quot;btn-check-outlined&quot; autocomplete=&quot;off&quot;&gt;\n                        &lt;\/div&gt;\n                    &lt;\/div&gt;\n                &lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n{% endfor %}\n<\/pre><\/div>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u53ef\u4ee5\u5148\u5f80\u6570\u636e\u5e93\u6dfb\u52a0\u4e00\u4e9b\u6570\u636e\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"382\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.03.02-1-1024x382.png\" alt=\"\" class=\"wp-image-6486\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.03.02-1-1024x382.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.03.02-1-300x112.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.03.02-1-768x286.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.03.02-1-769x287.png 769w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.03.02-1.png 1068w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u63a5\u7740\u6211\u4eec\u6765\u8fd0\u884c\u4e0b\u9879\u76ee\uff0c\u767b\u5f55\u8fdb\u5165\u7cfb\u7edf\uff0c\u6253\u5f00\u4efb\u52a1\u5217\u8868\u9875\u9762\uff0c\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5c55\u793a\u51fa\u6765\u4e86\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"307\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-1024x307.png\" alt=\"\" class=\"wp-image-6487\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-1024x307.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-300x90.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-768x230.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-1536x461.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-2048x614.png 2048w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-26-\u4e0a\u53481.05.06-769x231.png 769w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u56e0\u4e3a\u6211\u4eec\u7684\u4efb\u52a1\u521b\u5efa\u529f\u80fd\u5df2\u7ecf\u5b9e\u73b0\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8fd9\u91cc\u7ee7\u7eed\u521b\u5efa\u4efb\u52a1\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1455\" height=\"853\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/1.gif\" alt=\"\" class=\"wp-image-6488\"\/><\/figure>\n\n\n\n<p>\u6570\u636e\u5e93\u4e2d\u5b58\u50a8\u4e86<div style=\"text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;\">\u672c\u6587\u9690\u85cf\u5185\u5bb9 <a href=\"https:\/\/vip.fxxkpython.com\/wp-login.php?redirect_to=https%3A%2F%2Fvip.fxxkpython.com%2F%3Fp%3D6484\">\u767b\u9646<\/a> \u540e\u624d\u53ef\u4ee5\u6d4f\u89c8<\/div>\u5c31\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u5206\u522b\u5c55\u793a\u4e86\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1691\" height=\"853\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/2.gif\" alt=\"\" class=\"wp-image-6494\"\/><\/figure>\n\n\n\n<p>\u90a3\u4e48\u5f53\u6570\u636e\u6709\u5f88\u591a\u7684\u65f6\u5019\u5e94\u8be5\u5982\u4f55\u5904\u7406\u5462\uff1f\u6709\u6ca1\u6709\u66f4\u597d\u7684\u6570\u636e\u83b7\u53d6\u65b9\u5f0f\uff1f\u4ee5\u53ca\u70b9\u51fb\u5b8c\u6210\u529f\u80fd\u5982\u4f55\u5b9e\u73b0\uff1f<\/p>\n\n\n\n<p>\u6211\u4eec\u4e0b\u7bc7\u89c1\uff0cpeace\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73b0\u5728\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u4efb\u52a1\u521b\u5efa\u7684\u529f\u80fd\u4e86\uff0c\u63a5\u4e0b\u6765\u4f60\u5c31\u53ef\u4ee5\u5199\u83b7\u53d6\u6570\u636e\u7684\u63a5\u53e3\uff0c\u7136\u540e\u6e32\u67d3\u5230\u7f51\u9875\u4e2d\u53bb\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b9a\u4e49\u8def\u7531\u65b9\u6cd5\uff0c\u5728\u8fd9\u91cc\u6839\u636e\u4f20\u5165\u7684\u7528\u6237 id\uff0c\u5728\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u76f8\u5173\u7684\u4efb\u52a1\u5217\u8868\u6570\u636e\uff0c\u7136\u540e\u8fd4\u56de\u7ed9\u524d\u7aef\u9875\u9762\u3002 \u5982\u4f55\u83b7\u53d6\u4efb\u52a1\u5217\u8868\u6570\u636e\u5462\uff1f \u4e0a\u6b21\u6211\u4eec\u5728\u5efa\u7acb\u6570\u636e\u6a21\u578b\u7684\u65f6\u5019\uff0c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6494,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[99],"tags":[606,19,155,604,605],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6484"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6484"}],"version-history":[{"count":1,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6484\/revisions"}],"predecessor-version":[{"id":6495,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6484\/revisions\/6495"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/6494"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}