{"id":6472,"date":"2021-06-18T02:51:14","date_gmt":"2021-06-17T18:51:14","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=6472"},"modified":"2021-06-19T03:14:59","modified_gmt":"2021-06-18T19:14:59","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-15-%e7%af%87-%ef%bd%9c-%e4%b8%aa%e4%ba%ba%e8%ae%a1","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=6472","title":{"rendered":"\u4f7f\u7528 Python \u4ece 0 \u5f00\u53d1\u5c5e\u4e8e\u4f60\u7684\u4e2a\u4eba\u7ba1\u7406\u7cfb\u7edf 15 \u7bc7 \uff5c \u4e2a\u4eba\u8ba1\u5212\u529f\u80fd\u4e4b\u4efb\u52a1\u521b\u5efa"},"content":{"rendered":"\n<p>\u73b0\u5728\u6211\u4eec\u7684\u300c\u4e2a\u4eba\u8ba1\u5212\u300d\u539f\u578b\u5df2\u7ecf\u300c\u753b\u597d\u4e86\u300d\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u901a\u8fc7\u4ee3\u903b\u8f91\u6765\u5b9e\u73b0\u5b83\uff0c\u9996\u5148\u6211\u4eec\u6765\u5b9e\u73b0\u8fd9\u4e2a\u521b\u5efa\u4efb\u52a1\u7684\u90e8\u5206\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"593\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-1024x593.png\" alt=\"\" class=\"wp-image-6477\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-1024x593.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-300x174.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-768x445.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-1536x890.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-2048x1186.png 2048w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-18-\u4e0b\u534810.49.23-769x445.png 769w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u4ece\u4efb\u52a1\u7684\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u6765\u601d\u8003\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u8fd9\u6837\u7684\u4efb\u52a1\u529f\u80fd\uff0c\u6211\u4eec\u9700\u8981\u4ec0\u4e48\u6837\u7684\u6570\u636e\u5b57\u6bb5\u5462\uff1f<\/p><\/blockquote>\n\n\n\n<p>\u6700\u4e3b\u8981\u7684\u662f\uff1a\u4efb\u52a1\u7684\u5185\u5bb9\uff0c\u4efb\u52a1\u548c\u7528\u6237\u4e4b\u95f4\u7684\u5173\u8054\uff0c\u4ee5\u53ca\u4efb\u52a1\u662f\u5426\u5b8c\u6210\u7684\u6807\u5fd7\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u66f4\u52a0\u7ec6\u81f4\u4e00\u4e9b\uff0c\u8fd8\u53ef\u4ee5\u8003\u8651\u4efb\u52a1\u521b\u5efa\u7684\u65f6\u95f4\uff0c\u5b8c\u6210\u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<h2>\u6570\u636e\u5e93\u7684\u6dfb\u52a0<\/h2>\n\n\n\n<p>\u5728 model.py \u4e2d\uff0c\u521b\u5efa Todo \u7c7b\uff0c\u5c06\u5b57\u6bb5\u5b9a\u4e49\u597d\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\nclass Todo(db.Model):\n    __tablename__ = 'todo'\n    id = db.Column(db.Integer, primary_key=True)\n    description = db.Column(db.Text)\n    is_done = db.Column(db.Boolean, default=False)\n    create_time = db.Column(db.DateTime, index=True, default=datetime.now)\n    done_time = db.Column(db.DateTime, index=True)\n<\/pre><\/div>\n\n\n\n<h3>\u6570\u636e\u5e93\u4e2d\u7684\u5173\u7cfb\u521b\u5efa<\/h3>\n\n\n\n<p>\u4ec0\u4e48\u662f\u5173\u7cfb\uff1f<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u60f3\u4e00\u4e0b\uff0c\u4e00\u4e2a\u7528\u6237\uff0c\u662f\u4e0d\u662f\u53ef\u4ee5\u5173\u8054\u5f88\u591a\u4ed6\u81ea\u5df1\u521b\u5efa\u7684\u4efb\u52a1\uff1f<\/p>\n\n\n\n<p>\u800c\u8fd9\u79cd<strong>\u4e00\u5bf9\u591a<\/strong>\u7684\u5173\u7cfb\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u7684\u5916\u952e\u8fdb\u884c\u7ea6\u675f\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u521a\u521a\u521b\u5efa\u7684 Todo \u7c7b\u4e2d\uff0c\u6dfb\u52a0\u7ea6\u675f\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\nclass Todo(db.Model):\n    __tablename__ = 'todo'\n    id = db.Column(db.Integer, primary_key=True)\n    description = db.Column(db.Text)\n    is_done = db.Column(db.Boolean, default=False)\n    create_time = db.Column(db.DateTime, index=True, default=datetime.now)\n    done_time = db.Column(db.DateTime, index=True)\n    user_id = db.Column(db.Integer, db.ForeignKey('my_user.id')) # \u6dfb\u52a0\u7ea6\u675f\n\n<\/pre><\/div>\n\n\n\n<p>\u800c\u6211\u4eec\u4e4b\u524d\u521b\u5efa\u7684 User \u7c7b\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\nclass User(db.Model):\n    __tablename__ = 'my_user'\n    id = db.Column(db.Integer, primary_key=True)\n    username = db.Column(db.String(30), nullable=False)\n    admin_password = db.Column(db.String(120), nullable=False)\n<\/pre><\/div>\n\n\n\n<p>\u53ef\u4ee5\u4f7f\u7528<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%3D6472\">\u767b\u9646<\/a> \u540e\u624d\u53ef\u4ee5\u6d4f\u89c8<\/div>\u8fd9\u91cc\u6211\u4eec\u5c06\u5f97\u5230\u7684\u4efb\u52a1\u6570\u636e\u83b7\u53d6\u540e\uff0c\u751f\u6210\u6570\u636e\u5bf9\u8c61\u5e76\u6dfb\u52a0\u5230\u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u6765\u8fd0\u884c\u4e00\u4e0b\uff0c\u767b\u5f55\u5165\u7cfb\u7edf\uff0c\u8fdb\u5165\u4efb\u52a1\u9875\u9762\uff0c\u521b\u5efa\u5982\u4e0b\u4efb\u52a1\u4fe1\u606f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"119\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-1024x119.png\" alt=\"\" class=\"wp-image-6474\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-1024x119.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-300x35.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-768x89.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-1536x178.png 1536w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-2048x237.png 2048w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.44.25-769x89.png 769w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u6309\u4e0b\u56de\u8f66\u63d0\u4ea4\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u770b\u770b\u6570\u636e\u5e93\u662f\u5426\u6709\u4fe1\u606f\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"246\" src=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.46.12-1024x246.png\" alt=\"\" class=\"wp-image-6476\" srcset=\"https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.46.12-1024x246.png 1024w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.46.12-300x72.png 300w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.46.12-768x185.png 768w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.46.12-769x185.png 769w, https:\/\/vip.fxxkpython.com\/wp-content\/uploads\/2021\/06\/\u622a\u5c4f2021-06-19-\u4e0a\u53482.46.12.png 1032w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>OK\uff0c\u90a3\u4e48\u4efb\u52a1\u521b\u5efa\u7684\u8fc7\u7a0b\u5c31\u662f\u8fd9\u6837\u5566\uff0c\u8fd8\u6709\u4e00\u4e9b\u7ec6\u8282\u6211\u4eec\u53ef\u4ee5\u540e\u9762\u6162\u6162\u4f18\u5316\uff0c\u73b0\u5728\u4f60\u53ef\u4ee5\u5c06\u4efb\u52a1\u5217\u8868\u6570\u636e\u5c55\u793a\u5230\u9875\u9762\u4e2d\u561b\uff1f\u6211\u4eec\u4e0b\u56de\u89c1\uff0cpeace\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73b0\u5728\u6211\u4eec\u7684\u300c\u4e2a\u4eba\u8ba1\u5212\u300d\u539f\u578b\u5df2\u7ecf\u300c\u753b\u597d\u4e86\u300d\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u901a\u8fc7\u4ee3\u903b\u8f91\u6765\u5b9e\u73b0\u5b83\uff0c\u9996\u5148\u6211\u4eec\u6765\u5b9e\u73b0\u8fd9\u4e2a\u521b\u5efa\u4efb\u52a1\u7684\u90e8\u5206\uff1a \u4ece\u4efb\u52a1\u7684\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u6765\u601d\u8003\u4e00\u4e0b\uff1a \u8fd9\u6837\u7684\u4efb\u52a1\u529f\u80fd\uff0c\u6211\u4eec\u9700\u8981\u4ec0\u4e48\u6837\u7684\u6570\u636e\u5b57\u6bb5\u5462\uff1f \u6700\u4e3b\u8981\u7684\u662f\uff1a\u4efb\u52a1\u7684\u5185\u5bb9\uff0c\u4efb\u52a1\u548c\u7528\u6237\u4e4b\u95f4\u7684\u5173\u8054\uff0c\u4ee5\u53ca\u4efb\u52a1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6474,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[99],"tags":[549,602,552,603,100],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6472"}],"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=6472"}],"version-history":[{"count":4,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6472\/revisions"}],"predecessor-version":[{"id":6482,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6472\/revisions\/6482"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/media\/6474"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}