{"id":200,"date":"2018-10-07T10:24:55","date_gmt":"2018-10-07T10:24:55","guid":{"rendered":"http:\/\/develop-note.com\/blog\/?p=200"},"modified":"2022-02-16T22:19:36","modified_gmt":"2022-02-16T14:19:36","slug":"2019ironman-flask-restful-day06","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2018\/10\/07\/2019ironman-flask-restful-day06\/","title":{"rendered":"\u7b2c\u5341\u5c46\u9435\u4eba\u8cfd flask-restful DAY06-\u641e\u61c2Python\u7684\u7a0b\u5e8f\u7d50\u69cb"},"content":{"rendered":"<h1>Python\u7684\u7a0b\u5e8f\u7d50\u69cb<\/h1>\n<p>\u5728\u8aaa\u660ePyhton\u7684\u64b0\u5beb\u98a8\u683c\u4e4b\u5f8c\u53c8\u4ecb\u7d39\u4e86\u57fa\u672c\u578b\u5225\uff0c\u63a5\u4e0b\u4f86\u8981\u4ecb\u7d39\u7684\u662fPython\u7684\u7a0b\u5e8f\u7d50\u69cb\u3002\u4f55\u8b02\u7a0b\u5e8f\u7d50\u69cb\u5462\uff0c\u9867\u540d\u601d\u7fa9\u5c31\u662f\u7a0b\u5e8f\u9032\u884c\u7684\u65b9\u5411\u3002Python\u6709\u4e09\u7a2e\u7a0b\u5e8f\u7d50\u69cb\uff0c\u63a5\u4e0b\u4f86\u7b46\u8005\u6703\u4f9d\u5e8f\u8aaa\u660e\u9019\u4e09\u7a2e\u7a0b\u5e8f\u7d50\u69cb\uff1a<!--more--><\/p>\n<h2>\u9806\u5e8f\u7d50\u69cb<\/h2>\n<p>\u9019\u662fPython\u6700\u57fa\u672c\u7684\u7a0b\u5e8f\u7d50\u69cb\u4e5f\u662f\u6700\u5bb9\u6613\u8aaa\u660e\u7684\u7a0b\u5e8f\u7d50\u69cb\uff0c\u5176\u5be6\u5728\u524d\u9762\u5e7e\u7ae0\u7bc0\u5c31\u5df2\u7d93\u5229\u7528\u9019\u7a2e\u7a0b\u5e8f\u7d50\u69cb\u4ecb\u7d39Python\u597d\u5e7e\u6b21\u4e86\uff0c\u6240\u8b02\u9806\u5e8f\u7d50\u69cb\u5c31\u662f\u7531\u4e0a\u800c\u4e0b\u7531\u5de6\u81f3\u53f3\u4f86\u9032\u884c\u7a0b\u5e8f\uff0c\u66f4\u9032\u4e00\u6b65\u8aaa\u660e\u8acb\u898b\u4e0b\u9762\u4f8b\u5b50\uff1a<\/p>\n<pre><code class=\"language-python\">varA = 1\nvarB = 2\nvarC = varA * varB\nprint(varC)<\/code><\/pre>\n<p>\u76f8\u4fe1\u7d93\u904e\u524d\u9762\u5e7e\u7ae0\u7684\u4ecb\u7d39\u8b80\u8005\u61c9\u8a72\u80fd\u5920\u77ad\u89e3\u4e0a\u8ff0\u9019\u6bb5\u7a0b\u5f0f\u78bc\u518d\u8aaa\u751a\u9ebc\uff0c\u4ed6\u7684\u63cf\u8ff0\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>varA\u5b58\u653e\u4e00\u500b\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u653e\u7f6e\u6574\u65781\u7684\u4f4d\u5740<\/li>\n<li>varB\u5b58\u653e\u4e00\u500b\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u653e\u7f6e\u6574\u65782\u7684\u4f4d\u5740<\/li>\n<li>varC\u5b58\u653e\u4e00\u500b\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u8a08\u7b97<code><code>varA * varB<\/code><\/code>\u7d50\u679c\u7684\u4f4d\u5740<\/li>\n<li>\u5c07<code><code>varC<\/code><\/code>\u5217\u5370\u51fa\u4f86<br \/>\n\u5982\u958b\u982d\u8aaa\u660e\u7a0b\u5e8f\u7684\u884c\u9032\u662f\u7531\u4e0a\u800c\u4e0b\uff0c\u7531\u5de6\u81f3\u53f3\u7684\u65b9\u5f0f\u9032\u884c\uff0c\u4f46\u662f\u5176\u4e2d\u904b\u7b97\u5143\u53c8\u6709\u5176\u9032\u884c\u7684\u5148\u5f8c\u9806\u5e8f\uff0c\u6240\u4ee5\u4ee5\u4e0a\u7684\u4f8b\u5b50\u6700\u5f8c\u6703\u5370\u51fa2\u5728\u547d\u4ee4\u5217\u4e0a\u3002<\/li>\n<\/ol>\n<h2>\u908f\u8f2f\u7d50\u69cb<\/h2>\n<p>\u908f\u8f2f\u7d50\u69cb\u7684\u5167\u5bb9\u662f\u7576\u5224\u65b7\u689d\u4ef6\u662f\u6210\u7acb\u7684\u6642\u5f8c\u5c31\u9032\u5165\u57f7\u884c\u8a72\u9805\u7a0b\u5e8f\uff0c\u82e5\u4e0d\u6210\u7acb\u5c31\u7e7c\u7e8c\u6aa2\u67e5\u4e0b\u4e00\u9805\u908f\u8f2f\u5224\u65b7\uff0c\u7531\u4e0a\u5f80\u4e0b\u6aa2\u67e5\u76f4\u5230\u6700\u5f8c\uff0c\u6240\u4ee5\u4ee5\u4e0b\u5217\u4f8b\u5b50\u4f86\u8aaa\u660e\u908f\u8f2f\u7d50\u69cb\u7684\u64b0\u5beb\u65b9\u5f0f\uff1a<\/p>\n<pre><code class=\"language-python\">var = 10\nif var is 10:\n    print(&#039;var is 10&#039;)\nelif var is 20:\n    print(&#039;var is 20&#039;)\nelse:\n    print(&#039;var is else&#039;)<\/code><\/pre>\n<p>\u9019\u4f8b\u5b50\u5c31\u6bd4\u8f03\u9032\u968e\u4e00\u4e9b\u4e86\uff0c\u4e0d\u904e\u5b78\u904e\u7a0b\u5f0f\u8a9e\u8a00\u7684\u5c31\u77e5\u9053\u4ed6\u7684\u610f\u601d\u662f\u5148\u5224\u5c07<code><code>var<\/code>`<code>\u8ce6\u4e88\u4e00\u500b10\u7684\u8a18\u61b6\u9ad4\u4f4d\u7f6e\uff0c\u4e4b\u5f8c\u518d\u6aa2\u67e5<\/code>`<code>var<\/code>`<code>\u7684\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u662f\u5426\u70ba10\uff0c\u82e5\u662f\u5247\u57f7\u884c<\/code>`<code>print(&#039;var is 10&#039;)<\/code>`<code>\u82e5\u4e0d\u662f\u5247\u6aa2\u67e5\u4e0b\u4e00\u500b\u5f0f\u5b50<\/code>`<code>elif var is 20:<\/code>`<code>\u76f4\u5230\u5168\u90e8\u6aa2\u67e5\u5b8c\uff0c\u56e0\u70ba\u9019\u4f8b\u5b50\u4e2d<\/code>`<code>var<\/code>`<code>\u88ab\u8ce6\u4e88\u4e00\u500b10\u7684\u8a18\u61b6\u9ad4\u4f4d\u7f6e\uff0c\u6240\u4ee5\u5728<\/code>`<code>if var is 10:<\/code><\/code>\u5373\u6210\u7acb\uff0c\u6240\u4ee5\u5370\u51favar is 10\u5c31\u96e2\u958b\u8a72\u908f\u8f2f\u7d50\u69cb\u4e86\u3002<\/p>\n<h2>\u5faa\u74b0\u7d50\u69cb<\/h2>\n<p>\u5faa\u74b0\u7d50\u69cb\u5167\u5bb9\u662f\u7a0b\u5e8f\u6703\u4e0d\u65b7\u5730\u57f7\u884c\u8a72\u5faa\u74b0\u7d50\u69cb\u5167\u7684\u7a0b\u5e8f\uff0c\u76f4\u5230\u5faa\u74b0\u7d50\u69cb\u7684\u9650\u5236\u689d\u4ef6\u9054\u6210\u70ba\u6b62\uff0c\u82e5\u662f\u9650\u5236\u689d\u4ef6\u672a\u88ab\u6eff\u8db3\u5c31\u6703\u4e0d\u65b7\u5730\u57f7\u884c\u5c31\u50cf\u662f\u4e0b\u5217\u7684\u4f8b\u5b50<\/p>\n<pre><code class=\"language-python\">while 1:\n    print(&#039;no stop&#039;)<\/code><\/pre>\n<p>\u7576\u57f7\u884c\u4e0a\u8ff0\u4f8b\u5b50\u4e4b\u5f8c\u8b80\u8005\u5c07\u6703\u4e0d\u65b7\u770b\u5230no stop\u76f4\u5230\u8b80\u8005\u6848<code><code>ctrl + C<\/code>`<code>\u5f37\u5236\u4e2d\u65b7\u8a72\u7a0b\u5e8f\u624d\u6703\u505c\u6b62\uff0c\u6240\u4ee5\u5728\u5beb\u5faa\u74b0\u7d50\u69cb\u6642\u8acb\u5148\u8a2d\u5b9a\u597d\u7d50\u675f\u689d\u4ef6\u907f\u514d\u7121\u7aae\u8ff4\u5708\u7684\u7522\u751f\u3002\u5728\u8aaa\u660e\u5b8c<\/code>`<code>while<\/code>`<code>\u7684\u4f8b\u5b50\u5f8c\u518d\u8aaa\u660e<\/code>`<code>for<\/code><\/code>\u7684\u4f8b\u5b50:<\/p>\n<pre><code class=\"language-python\">for x in range(1:10):\n    for y in range(1:10):\n        print(&#039;{0} * {1} = {2}&#039;.format(x, y, x * y))<\/code><\/pre>\n<p>\u9019\u5c31\u662f<code><code>for<\/code><\/code>\u5e38\u793a\u7bc4\u768499\u4e58\u6cd5\u8868<\/p>\n<h1>\u5c0f\u7d50<\/h1>\n<p>\u5230\u9019\u908a\u4e00\u822c\u7684Python\u8a9e\u6cd5\u4ecb\u7d39\u544a\u4e00\u6bb5\u843d\u4e86\uff0c\u5982\u6b64\u5df2\u7d93\u53ef\u4ee5\u958b\u59cb\u958b\u767c\u4e00\u4e9b\u5c0f\u7a0b\u5e8f\u4e86\u3002\u56e0\u70ba\u89c0\u5ff5\u7684\u90e8\u5206\u5f88\u5bb9\u6613\u6709\u89c0\u5ff5\u932f\u8aa4\u7684\u5730\u65b9\uff0c\u800c\u4e14\u6c92\u6709\u4eba\u63d0\u9ede\u9084\u6703\u4e0d\u81ea\u89ba\u7684\u932f\u4e0b\u53bb\uff0c\u6240\u4ee5\u5beb\u932f\u7684\u5730\u65b9\u6709\u554f\u984c\u9084\u4f86\u4fe1\u544a\u77e5\u5594\u3002\u6700\u5f8c\u4e0d\u65b7\u5730\u5beb\u540c\u6a23\u7684\u7a0b\u5f0f\u662f\u4e0d\u7b26\u5408\u5de5\u7a0b\u5e2b\u7684\u7cbe\u795e\uff0c\u4e0b\u4e00\u7ae0\u6703\u958b\u59cb\u4ecb\u7d39\u65b9\u6cd5\u7684\u64b0\u5beb\u65b9\u5f0f\uff0c\u656c\u8acb\u671f\u5f85\u5594\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u7684\u7a0b\u5e8f\u7d50\u69cb \u5728\u8aaa\u660ePyhton\u7684\u64b0\u5beb\u98a8\u683c\u4e4b\u5f8c\u53c8\u4ecb\u7d39\u4e86\u57fa\u672c\u578b\u5225\uff0c\u63a5\u4e0b\u4f86\u8981\u4ecb\u7d39\u7684\u662fPython\u7684\u7a0b\u5e8f\u7d50 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2018\/10\/07\/2019ironman-flask-restful-day06\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u7b2c\u5341\u5c46\u9435\u4eba\u8cfd flask-restful DAY06-\u641e\u61c2Python\u7684\u7a0b\u5e8f\u7d50\u69cb\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[162,4,5,3],"class_list":["post-200","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2018ironman","tag-flask","tag-flask-restful","tag-python"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=200"}],"version-history":[{"count":15,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":2764,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/200\/revisions\/2764"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}