{"id":160,"date":"2018-10-06T10:00:42","date_gmt":"2018-10-06T10:00:42","guid":{"rendered":"https:\/\/develop-note.com\/blog\/?p=160"},"modified":"2022-02-16T22:19:52","modified_gmt":"2022-02-16T14:19:52","slug":"2019ironman-flask-restful-day05","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2018\/10\/06\/2019ironman-flask-restful-day05\/","title":{"rendered":"\u7b2c\u5341\u5c46\u9435\u4eba\u8cfd flask-restful DAY05-\u641e\u61c2Python\u7684\u5167\u5efa\u578b\u5225"},"content":{"rendered":"<h1>Python\u7684\u5167\u5efa\u578b\u5225<\/h1>\n<p>\u5728\u4ecb\u7d39\u5b8cPython\u7684\u64b0\u5beb\u98a8\u683c\u5f8c\uff0c\u76f8\u4fe1\u5927\u5bb6\u5c0dPython\u5df2\u7d93\u6709\u521d\u6b65\u7684\u8a8d\u8b58\uff0c\u672c\u7ae0\u6703\u958b\u59cb\u4ecb\u7d39Python\u7684\u57fa\u672c\u8a9e\u6cd5\uff0c\u4e0d\u904e\u9084\u662f\u5982\u540c\u4e0a\u4e00\u7ae0\u4e00\u6a23\uff0c\u82e5\u662f\u5df2\u7d93\u6703\u5bebPython\u7684\u8b80\u8005\u8acb\u7576\u4f5c\u8907\u7fd2\uff0c\u4e0d\u4fbf\u4e4b\u8655\u656c\u8acb\u898b\u8ad2\u3002<!--more--><\/p>\n<h1>\u57fa\u672c\u578b\u5225<\/h1>\n<p>\u96d6\u7136Python\u5ba3\u544a\u8b8a\u6578\u6642\u4e0d\u9700\u8a02\u55ae\u8b8a\u6578\u578b\u5225\u3001\u7d66\u503c\u4e5f\u4e0d\u7ba1\u8b8a\u6578\u578b\u5225\uff0c\u4f46\u662f\u5728\u578b\u5225\u7684\u904b\u7b97\u662f\u4e0d\u5141\u8a31\u7684\uff0c\u56e0\u6b64\u5728\u9019\u7bc0\u5148\u4ecb\u7d39Python\u6709\u54ea\u4e9b\u578b\u5225\uff0c\u518d\u4ecb\u7d39\u5982\u4f55\u8b8a\u6578\u8f49\u63db\u578b\u5225\u3002<\/p>\n<h2>\u578b\u5225\u7a2e\u985e<\/h2>\n<p>\u9996\u5148\u5728\u9019\u5c0f\u7bc0\u5148\u7f85\u5217Python\u6709\u54ea\u4e9b\u57fa\u672c\u578b\u5225\u4ee5\u53ca\u5176\u7528\u9014\uff1a<\/p>\n<ul>\n<li>\n<p>\u5e03\u6797\u503c<code><code>bool<\/code>`<code>\u9019\u500b\u578b\u5225\u5c31\u4ee3\u8868\u8457\u771f<\/code>`<code>True<\/code>`<code>\u6216\u5047<\/code>`<code>False<\/code><\/code>\u4ed6\u662f\u63a7\u5236\u6d41\u7a0b\u7684\u597d\u5e6b\u624b<\/p>\n<\/li>\n<li>\n<p>\u6574\u6578<code><code>int<\/code>`<code>\u9019\u500b\u578b\u5225\u5c31\u662f\u4e0d\u5e36\u5c0f\u6578\u9ede\u7684\u6578\uff0c\u4f8b\u5982<\/code>`<code>123<\/code><\/code>\u662f\u6574\u6578<\/p>\n<\/li>\n<li>\n<p>\u6d6e\u9ede\u6578<code><code>float<\/code>`<code>\u76f8\u7576\u65bc\u6574\u6578\uff0c\u6d6e\u9ede\u6578\u5c31\u662f\u5e36\u5c0f\u6578\u9ede\u7684\u6578\uff0c\u4f8b\u5982<\/code>`<code>123.124<\/code><\/code>\u662f\u6d6e\u9ede\u6578<\/p>\n<\/li>\n<li>\n<p>\u5b57\u4e32<code><code>string<\/code>`<code>\u5b57\u4e32\u5c31\u662f\u6211\u5011\u4e00\u822c\u5728\u4f7f\u7528\u7684\u6587\u5b57\uff0c\u4ed6\u7684\u4f7f\u7528\u65b9\u5f0f\u5c31\u662f\u7528\u55ae\u6216\u96d9\u5f15\u865f\u628a\u5167\u5bb9\u5305\u8d77\u4f86\uff0c\u6240\u4ee5<\/code>`<code>&#039;123.123&#039;<\/code><\/code>\u5247\u662f\u5b57\u4e32<\/p>\n<h2>\u5982\u4f55\u8f49\u578b<\/h2>\n<p>\u4ecb\u7d39\u5b8c\u578b\u5225\u5f8c\u9700\u8981\u4ecb\u7d39\u8f49\u578b\uff0c\u56e0\u70ba\u4e0d\u540c\u578b\u5225\u4e4b\u9593\u7684\u904b\u7b97\u8655\u7406\u53ef\u80fd\u6703\u9020\u6210\u7a0b\u5e8f\u7570\u5e38\u4e2d\u65b7\uff0c\u5c31\u8b93\u5927\u5bb6\u770b\u770b\u4ee5\u4e0b\u4f8b\u5b50\uff1a<\/p>\n<pre><code class=\"language-python\">level = &#039;123&#039;\nnum = 1 + (level * 1)<\/code><\/pre>\n<p>\u8b80\u8005\u53ef\u4ee5\u8a66\u8a66\u770b\u9019\u6bb5\u7a0b\u5f0f\u78bc\uff0c\u76f8\u4fe1\u5927\u5bb6\u53ef\u4ee5\u770b\u5230\u57f7\u884c\u5230\u9019\u7a0b\u5f0f\u78bc\u6703\u7570\u5e38\u4e2d\u6bb5\uff0c\u4e26\u986f\u793a\u932f\u8aa4\u8a0a\u606f\uff0c\u5982\u679c\u8981\u6b63\u5e38\u904b\u4f5c\u5c31\u9700\u8981\u8f49\u578b\uff0c\u8f49\u578b\u7684\u65b9\u5f0f\u4f9d\u7167\u6b32\u8f49\u63db\u7684\u76ee\u6a19\u578b\u5225\u7f85\u5217\u5982\u4e0b\uff1a<\/p>\n<\/li>\n<li>\n<p>\u5e03\u6797bool()<\/p>\n<\/li>\n<li>\n<p>\u6574\u6578int()<\/p>\n<\/li>\n<li>\n<p>\u6d6e\u9ede\u6578float()<\/p>\n<\/li>\n<li>\n<p>\u5b57\u4e32str()<br \/>\n\u6240\u4ee5\u8981\u89e3\u6c7a\u4e0a\u8ff0\u5f0f\u5b50\u6240\u5f15\u8d77\u7684\u7570\u5e38\u4e2d\u65b7\u5c31\u9700\u8981\u6539\u5beb\u6210\u4e0b\u8ff0\u5167\u5bb9<\/p>\n<pre><code class=\"language-python\">level = &#039;123&#039;\nnum = 1 + (int(level) * 1)<\/code><\/pre>\n<p>\u4e5f\u5c31\u628a\u8b8a\u6578<code><code>level<\/code><\/code>\u7531\u5b57\u4e32\u8f49\u578b\u6210\u6574\u6578\u3002<\/p>\n<\/li>\n<\/ul>\n<h1>\u96c6\u5408\u578b\u5225<\/h1>\n<p>\u4ecb\u7d39\u5b8c\u57fa\u672c\u578b\u5225\u4e4b\u5f8c\u63a5\u8457\u8981\u4ecb\u7d39\u96c6\u5408\u578b\u5225\u7d66\u5404\u4f4d\u8b80\u8005\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f\u96c6\u5408\u578b\u5225<\/h2>\n<p>\u96c6\u5408\u578b\u5225\u8ddf\u57fa\u672c\u578b\u5225\u4e4b\u9593\u7684\u95dc\u4fc2\u7c21\u55ae\u8b1b\u5c31\u662f\u6709\u8a31\u591a\u57fa\u672c\u578b\u5225\u7d44\u5408\u800c\u6210\u5c31\u662f\u96c6\u5408\u578b\u5225\u3002<\/p>\n<h3>\u96c6\u5408\u578b\u5225\u7684\u985e\u578b<\/h3>\n<ul>\n<li>\u4e32\u5217<code><code>list<\/code><\/code>\u4e00\u7a2e\u7531\u57fa\u672c\u578b\u5225\u4e32\u6210\u4e00\u4e32\u7684\u578b\u5225<\/li>\n<li>\u5143\u7d44<code><code>tuple<\/code><\/code>\u985e\u4f3c\u4e32\u5217\u7684\u578b\u5225\uff0c\u4f46\u662f\u7d66\u5b9a\u5f8c\u4e0d\u80fd\u66f4\u6539\u5176\u5305\u542b\u5143\u7d20\u7684\u5167\u5bb9\u7684\u578b\u5225<\/li>\n<li>\u5b57\u5178<code><code>dict<\/code><\/code>\u985e\u4f3c\u4e32\u5217\uff0c\u4f46\u662f\u4ed6\u662f\u7531key\u5c0d\u61c9\u7684value\u7684\u4e00\u7a2e\u578b\u5225\uff0c\u800c\u4e0d\u50cf\u4e32\u5217\u662f\u7531\u6574\u6578\u7684\u7d22\u5f15\u503c\u4f86\u5c0d\u61c9\u5230\u8a72\u4f4d\u7f6e\u8b8a\u6578\u7684\u4e00\u7a2e\u578b\u5225<\/li>\n<li>\u96c6\u5408<code><code>set<\/code><\/code>\u985e\u4f3c\u4e32\u5217\u4f46\u662f\u5176\u5167\u5143\u7d20\u4e0d\u53ef\u91cd\u8907<br \/>\n<h2>\u4e0d\u53ef\u8b8a\u578b\u5225\u8207\u53ef\u8b8a\u578b\u5225<\/h2>\n<h3>\u9019\u53c8\u662f\u4ec0\u9ebc<\/h3>\n<p>\u7531\u8b8a\u6578\u662f\u5426\u53ef\u88ab\u6539\u8b8a\u4f86\u5206\u985e\u578b\u5225\u53c8\u53ef\u5206\u70ba\u4ee5\u4e0a\u5169\u7a2e\u578b\u5225\uff0c\u4e4b\u5f8c\u518d\u5206\u5225\u4ecb\u7d39\u9019\u5169\u7a2e\u578b\u5225\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e0d\u53ef\u8b8a\u578b\u5225<\/h3>\n<p>\u9019\u578b\u5225\u7684\u7279\u6027\u662f\u4f60\u7121\u6cd5\u6539\u8b8a\u8b8a\u6578\u6240\u5305\u542b\u8cc7\u6599\u7684\u5167\u5bb9\u7684\u4e00\u7a2e\u578b\u5225\uff0c\u7d93\u904e\u4e0a\u8ff0\u8aaa\u660e\u61c9\u8a72\u6c92\u591a\u5c11\u4eba\u80fd\u66b8\u89e3\u5728\u8aaa\u4ec0\u9ebc\uff0c\u6240\u4ee5\u5148\u770b\u770b\u4ee5\u4e0b\u4f8b\u5b50\uff1a<\/p>\n<pre><code class=\"language-python\">var = 1\nvar = 2<\/code><\/pre>\n<p>\u9019\u4f8b\u5b50\u662f\u5148\u7522\u751f\u8a18\u61b6\u9ad4\u7a7a\u9593\u5b58\u653e1\u4e26\u628a\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u8a18\u8f09<code><code>var<\/code>`<code>\u5167\uff0c\u7576<\/code>`<code>var<\/code>`<code>\u6539\u8ce6\u4e882\u6642\u662f\u53e6\u5916\u7522\u751f\u8a18\u61b6\u9ad4\u7a7a\u9593\u5b58\u653e2\u800c\u975e\u6539\u8b8a\u539f\u4f86\u7684\u8a18\u61b6\u9ad4\u7a7a\u9593\u5167\u7684\u503c\uff0c\u6240\u4ee5<\/code>`<code>var<\/code><\/code>\u7684\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u6703\u6539\u8b8a\u70ba\u5b58\u653e2\u7684\u8a18\u61b6\u9ad4\u4f4d\u5740\u3002\u89e3\u91cb\u5b8c\u4ec0\u9ebc\u662f\u4e0d\u53ef\u8b8a\u8b8a\u6578\u4e4b\u5f8c\u5c31\u4f86\u770b\u770b\u54ea\u4e9b\u662f\u4e0d\u53ef\u8b8a\u8b8a\u6578\uff0c\u5176\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\n<p>\u5e03\u6797<\/p>\n<\/li>\n<li>\n<p>\u6574\u6578<\/p>\n<\/li>\n<li>\n<p>\u6d6e\u9ede\u6578<\/p>\n<\/li>\n<li>\n<p>\u5b57\u4e32<\/p>\n<\/li>\n<li>\n<p>\u5143\u7d44<\/p>\n<h3>\u53ef\u8b8a\u8b8a\u6578<\/h3>\n<p>\u76f8\u5c0d\u65bc\u4e0d\u53ef\u8b8a\u8b8a\u6578\uff0c\u53ef\u8b8a\u8b8a\u6578\u53ef\u4ee5\u66f4\u6539\u6240\u5305\u542b\u8b8a\u6578\u5167\u5bb9\u7684\u4e00\u7a2e\u578b\u5225\uff0c\u5176\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/li>\n<li>\n<p>\u4e32\u5217<\/p>\n<\/li>\n<li>\n<p>\u96c6\u5408<\/p>\n<\/li>\n<li>\n<p>\u5b57\u5178<br \/>\n\u89e3\u91cb\u5b8c\u4e0d\u53ef\u8b8a\u578b\u5225\u5f8c\uff0c\u8981\u89e3\u91cb\u53ef\u8b8a\u578b\u5225\u5c31\u5bb9\u6613\u591a\u4e86\uff0c\u53ef\u8b8a\u8b8a\u6578\u5c31\u662f\u7576\u6539\u8b8a\u5176\u5167\u5bb9\u6642\u5176\u8a18\u61b6\u9ad4\u4f4d\u7f6e\u4e0d\u6703\u8b8a\u66f4\u800c\u6703\u76f4\u63a5\u66f4\u6539\u5167\u5bb9\u7269\u7684\u503c\u3002<\/p>\n<\/li>\n<\/ul>\n<h1>\u5c0f\u7d50<\/h1>\n<p>\u597d\u4e86\u7d42\u65bc\u4ecb\u7d39\u5b8cPyhton\u7684\u578b\u5225\u4e86\uff0c\u56e0\u70ba\u9019\u90e8\u5206\u89c0\u5ff5\u554f\u984c\u5f88\u5bb9\u6613\u8a18\u932f\uff0c\u5982\u679c\u6709\u8aaa\u932f\u7684\u9084\u9ebb\u7169\u544a\u8a34\u6211\u4e00\u8072\uff0c\u63a5\u4e0b\u4f86\u6703\u4ecb\u7d39Python\u7684\u4e09\u7a2e\u7a0b\u5f0f\u7d50\u69cb\uff0c\u656c\u8acb\u671f\u5f85\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u7684\u5167\u5efa\u578b\u5225 \u5728\u4ecb\u7d39\u5b8cPython\u7684\u64b0\u5beb\u98a8\u683c\u5f8c\uff0c\u76f8\u4fe1\u5927\u5bb6\u5c0dPython\u5df2\u7d93\u6709\u521d\u6b65\u7684\u8a8d\u8b58\uff0c\u672c\u7ae0\u6703\u958b\u59cb\u4ecb &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2018\/10\/06\/2019ironman-flask-restful-day05\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u7b2c\u5341\u5c46\u9435\u4eba\u8cfd flask-restful DAY05-\u641e\u61c2Python\u7684\u5167\u5efa\u578b\u5225\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-160","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\/160","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=160"}],"version-history":[{"count":40,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":2765,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions\/2765"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}