{"id":979671,"date":"2024-12-27T06:48:25","date_gmt":"2024-12-26T22:48:25","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/979671.html"},"modified":"2024-12-27T06:48:27","modified_gmt":"2024-12-26T22:48:27","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8python%e5%86%99%e7%bd%91%e9%a1%b5","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/979671.html","title":{"rendered":"\u5982\u4f55\u4f7f\u7528python\u5199\u7f51\u9875"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205414\/37e7f0ca-55ca-45c4-ad78-de6fff956865.webp\" alt=\"\u5982\u4f55\u4f7f\u7528python\u5199\u7f51\u9875\" \/><\/p>\n<p><p> \u4f7f\u7528Python\u7f16\u5199\u7f51\u9875\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0\uff0c\u4e3b\u8981\u5305\u62ec<strong>\u4f7f\u7528Web\u6846\u67b6\u3001\u7f16\u5199\u670d\u52a1\u5668\u7aef\u4ee3\u7801\u3001\u96c6\u6210\u6570\u636e\u5e93<\/strong>\u7b49\u51e0\u79cd\u65b9\u5f0f\u3002\u9996\u5148\uff0cPython\u63d0\u4f9b\u4e86\u5f88\u591a\u5f3a\u5927\u7684Web\u6846\u67b6\uff0c\u5982Django\u3001Flask\u7b49\uff0c\u5b83\u4eec\u53ef\u4ee5\u5e2e\u52a9\u5feb\u901f\u642d\u5efa\u548c\u5f00\u53d1Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u6b21\uff0cPython\u4ee3\u7801\u53ef\u4ee5\u7528\u4e8e\u670d\u52a1\u5668\u7aef\u5904\u7406\uff0c\u751f\u6210\u52a8\u6001\u5185\u5bb9\u5e76\u54cd\u5e94\u7528\u6237\u8bf7\u6c42\u3002\u6700\u540e\uff0cPython\u53ef\u4ee5\u8f7b\u677e\u96c6\u6210\u6570\u636e\u5e93\uff0c\u5b9e\u73b0\u6570\u636e\u5b58\u50a8\u548c\u7ba1\u7406\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528WEB\u6846\u67b6<\/p>\n<\/p>\n<p><p>Python\u7684Web\u6846\u67b6\u662f\u6784\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u57fa\u7840\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u4e00\u6574\u5957\u5de5\u5177\u548c\u5e93\u6765\u7b80\u5316Web\u5f00\u53d1\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<ol>\n<li>Django\u6846\u67b6<\/li>\n<\/ol>\n<p><p>Django\u662f\u4e00\u4e2a\u9ad8\u7ea7\u7684Python Web\u6846\u67b6\uff0c\u65e8\u5728\u5feb\u901f\u5f00\u53d1\u548c\u7b80\u5316\u590d\u6742\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u9075\u5faa\u201c\u5feb\u901f\u5f00\u53d1\u201d\u548c\u201c\u4e0d\u8981\u91cd\u590d\u81ea\u5df1\u201d\u7684\u539f\u5219\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u5feb\u901f\u5f00\u53d1<\/strong>\uff1aDjango\u5185\u7f6e\u4e86\u8bb8\u591a\u529f\u80fd\uff0c\u5982\u7ba1\u7406\u540e\u53f0\u3001ORM\uff08\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff09\u3001\u8ba4\u8bc1\u7cfb\u7edf\u7b49\uff0c\u8fd9\u4e9b\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u7f51\u7ad9\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5f3a\u5927\u7684ORM<\/strong>\uff1aDjango\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5e93\u63a5\u53e3\uff0c\u53ef\u4ee5\u8f7b\u677e\u4e0e\u591a\u79cd\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u8981\u5f00\u59cb\u4f7f\u7528Django\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Django\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install django<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u5e76\u8fd0\u884c\u670d\u52a1\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">django-admin startproject mysite<\/p>\n<p>cd mysite<\/p>\n<p>python manage.py runserver<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>Flask\u6846\u67b6<\/li>\n<\/ol>\n<p><p>Flask\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684Python Web\u6846\u67b6\uff0c\u9002\u5408\u4e8e\u5c0f\u578b\u9879\u76ee\u548c\u5fae\u670d\u52a1\u3002\u5b83\u7684\u8bbe\u8ba1\u54f2\u5b66\u662f\u7b80\u5355\u6613\u7528\uff0c\u7075\u6d3b\u6027\u9ad8\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u7075\u6d3b\u6027<\/strong>\uff1a\u4e0eDjango\u76f8\u6bd4\uff0cFlask\u63d0\u4f9b\u4e86\u66f4\u5c11\u7684\u5185\u7f6e\u529f\u80fd\uff0c\u4f46\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u6839\u636e\u9700\u8981\u9009\u62e9\u9002\u5408\u7684\u7b2c\u4e09\u65b9\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7b80\u5355\u6613\u7528<\/strong>\uff1aFlask\u7684API\u975e\u5e38\u76f4\u89c2\uff0c\u9002\u5408\u521d\u5b66\u8005\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u5b89\u88c5Flask\u5e76\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install flask<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Flask\u5e94\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from flask import Flask<\/p>\n<p>app = Flask(__name__)<\/p>\n<p>@app.route(&#39;\/&#39;)<\/p>\n<p>def hello_world():<\/p>\n<p>    return &#39;Hello, World!&#39;<\/p>\n<p>if __name__ == &#39;__m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n__&#39;:<\/p>\n<p>    app.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u7f16\u5199\u670d\u52a1\u5668\u7aef\u4ee3\u7801<\/p>\n<\/p>\n<p><p>Python\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u7f16\u5199\u5ba2\u6237\u7aef\u4ee3\u7801\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u7f16\u5199\u670d\u52a1\u5668\u7aef\u903b\u8f91\uff0c\u8fd9\u5305\u62ec\u5904\u7406HTTP\u8bf7\u6c42\u3001\u751f\u6210\u52a8\u6001\u5185\u5bb9\u3001\u7ba1\u7406\u7528\u6237\u4f1a\u8bdd\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5904\u7406HTTP\u8bf7\u6c42<\/li>\n<\/ol>\n<p><p>\u5728Web\u5f00\u53d1\u4e2d\uff0c\u5904\u7406HTTP\u8bf7\u6c42\u662f\u670d\u52a1\u5668\u7aef\u7684\u6838\u5fc3\u4efb\u52a1\u4e4b\u4e00\u3002Python\u53ef\u4ee5\u901a\u8fc7Web\u6846\u67b6\u6216\u8005\u539f\u751f\u5e93\u6765\u5904\u7406\u8fd9\u4e9b\u8bf7\u6c42\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u8bf7\u6c42\u5bf9\u8c61<\/strong>\uff1a\u5927\u591a\u6570Web\u6846\u67b6\u90fd\u4f1a\u63d0\u4f9b\u4e00\u4e2a\u8bf7\u6c42\u5bf9\u8c61\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u5b83\u83b7\u53d6\u8bf7\u6c42\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5982\u8bf7\u6c42\u8def\u5f84\u3001\u53c2\u6570\u3001\u5934\u4fe1\u606f\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u54cd\u5e94\u5bf9\u8c61<\/strong>\uff1a\u5728\u5904\u7406\u5b8c\u8bf7\u6c42\u540e\uff0c\u670d\u52a1\u5668\u9700\u8981\u8fd4\u56de\u4e00\u4e2a\u54cd\u5e94\u5bf9\u8c61\uff0c\u5305\u542b\u54cd\u5e94\u72b6\u6001\u7801\u3001\u5934\u4fe1\u606f\u3001\u6b63\u6587\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u751f\u6210\u52a8\u6001\u5185\u5bb9<\/li>\n<\/ol>\n<p><p>\u52a8\u6001\u5185\u5bb9\u662f\u73b0\u4ee3Web\u5e94\u7528\u7a0b\u5e8f\u7684\u6838\u5fc3\u3002Python\u670d\u52a1\u5668\u7aef\u4ee3\u7801\u53ef\u4ee5\u6839\u636e\u7528\u6237\u8f93\u5165\u6216\u5176\u4ed6\u6761\u4ef6\u52a8\u6001\u751f\u6210HTML\u9875\u9762\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u6a21\u677f\u5f15\u64ce<\/strong>\uff1aDjango\u548cFlask\u90fd\u652f\u6301\u6a21\u677f\u5f15\u64ce\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u5c06Python\u4ee3\u7801\u548cHTML\u6df7\u5408\u4f7f\u7528\uff0c\u4ee5\u751f\u6210\u52a8\u6001\u9875\u9762\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Jinja2\u6a21\u677f\u5f15\u64ce<\/strong>\uff1aFlask\u4f7f\u7528Jinja2\u4f5c\u4e3a\u9ed8\u8ba4\u6a21\u677f\u5f15\u64ce\uff0c\u5b83\u652f\u6301\u63a7\u5236\u7ed3\u6784\u3001\u53d8\u91cf\u66ff\u6362\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u4e09\u3001\u96c6\u6210\u6570\u636e\u5e93<\/p>\n<\/p>\n<p><p>\u6570\u636e\u5e93\u662fWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\uff0c\u5b83\u7528\u4e8e\u5b58\u50a8\u548c\u7ba1\u7406\u6570\u636e\u3002Python\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u96c6\u6210\u548c\u64cd\u4f5c\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528ORM<\/li>\n<\/ol>\n<p><p>Django\u5185\u7f6e\u4e86\u5f3a\u5927\u7684ORM\u7cfb\u7edf\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u4ee5\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\u64cd\u4f5c\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u6a21\u578b\u5b9a\u4e49<\/strong>\uff1a\u5f00\u53d1\u8005\u901a\u8fc7\u5b9a\u4e49\u6a21\u578b\u7c7b\u6765\u63cf\u8ff0\u6570\u636e\u5e93\u8868\u7684\u7ed3\u6784\u3002\u6bcf\u4e2a\u6a21\u578b\u7c7b\u5bf9\u5e94\u4e00\u4e2a\u6570\u636e\u5e93\u8868\uff0c\u6bcf\u4e2a\u7c7b\u5c5e\u6027\u5bf9\u5e94\u4e00\u4e2a\u8868\u5b57\u6bb5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u67e5\u8be2\u63a5\u53e3<\/strong>\uff1aDjango ORM\u63d0\u4f9b\u4e86\u4e00\u6574\u5957\u4e30\u5bcc\u7684\u67e5\u8be2\u63a5\u53e3\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u590d\u6742\u7684\u67e5\u8be2\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u4f7f\u7528SQLAlchemy<\/li>\n<\/ol>\n<p><p>Flask\u63a8\u8350\u4f7f\u7528SQLAlchemy\u4f5c\u4e3aORM\u5de5\u5177\uff0c\u5b83\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5e93\u5de5\u5177\u5305\uff0c\u652f\u6301\u591a\u79cd\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u7075\u6d3b\u6027<\/strong>\uff1aSQLAlchemy\u63d0\u4f9b\u4e86\u6bd4Django ORM\u66f4\u7075\u6d3b\u7684\u67e5\u8be2\u80fd\u529b\uff0c\u652f\u6301\u590d\u6742\u7684\u67e5\u8be2\u548c\u5173\u7cfb\u6620\u5c04\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u96c6\u6210Flask<\/strong>\uff1aFlask-SQLAlchemy\u662fFlask\u7684\u6269\u5c55\u5305\uff0c\u53ef\u4ee5\u65e0\u7f1d\u96c6\u6210SQLAlchemy\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u56db\u3001\u5b9e\u73b0\u7528\u6237\u8ba4\u8bc1\u548c\u6388\u6743<\/p>\n<\/p>\n<p><p>\u7528\u6237\u8ba4\u8bc1\u548c\u6388\u6743\u662fWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u57fa\u672c\u529f\u80fd\uff0c\u7528\u4e8e\u4fdd\u62a4\u5e94\u7528\u7a0b\u5e8f\u7684\u5b89\u5168\u3002<\/p>\n<\/p>\n<ol>\n<li>\u7528\u6237\u8ba4\u8bc1<\/li>\n<\/ol>\n<p><p>\u7528\u6237\u8ba4\u8bc1\u662f\u9a8c\u8bc1\u7528\u6237\u8eab\u4efd\u7684\u8fc7\u7a0b\u3002Django\u5185\u7f6e\u4e86\u5b8c\u5584\u7684\u7528\u6237\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u7528\u6237\u6ce8\u518c\u3001\u767b\u5f55\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u7528\u6237\u6a21\u578b<\/strong>\uff1aDjango\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u7684\u7528\u6237\u6a21\u578b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6269\u5c55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8ba4\u8bc1\u89c6\u56fe<\/strong>\uff1aDjango\u7684\u8ba4\u8bc1\u89c6\u56fe\u5305\u62ec\u767b\u5f55\u3001\u6ce8\u9500\u3001\u5bc6\u7801\u91cd\u7f6e\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u6216\u81ea\u5b9a\u4e49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u7528\u6237\u6388\u6743<\/li>\n<\/ol>\n<p><p>\u7528\u6237\u6388\u6743\u662f\u63a7\u5236\u7528\u6237\u8bbf\u95ee\u6743\u9650\u7684\u8fc7\u7a0b\u3002Django\u63d0\u4f9b\u4e86\u57fa\u4e8e\u7ec4\u548c\u6743\u9650\u7684\u6388\u6743\u673a\u5236\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u6743\u9650\u6a21\u578b<\/strong>\uff1a\u5f00\u53d1\u8005\u53ef\u4ee5\u4e3a\u4e0d\u540c\u7684\u6a21\u578b\u548c\u89c6\u56fe\u5b9a\u4e49\u6743\u9650\uff0c\u63a7\u5236\u7528\u6237\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ec4\u7ba1\u7406<\/strong>\uff1aDjango\u5141\u8bb8\u5c06\u7528\u6237\u5212\u5206\u4e3a\u4e0d\u540c\u7684\u7ec4\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u7ec4\u5206\u914d\u4e0d\u540c\u7684\u6743\u9650\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u4e94\u3001\u90e8\u7f72Python Web\u5e94\u7528<\/p>\n<\/p>\n<p><p>\u5f00\u53d1\u5b8c\u6210\u7684Python Web\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u90e8\u7f72\u5230\u670d\u52a1\u5668\u4e0a\uff0c\u4ee5\u4fbf\u7528\u6237\u8bbf\u95ee\u3002<\/p>\n<\/p>\n<ol>\n<li>\u9009\u62e9\u670d\u52a1\u5668<\/li>\n<\/ol>\n<p><p>Python Web\u5e94\u7528\u53ef\u4ee5\u90e8\u7f72\u5728\u591a\u79cd\u670d\u52a1\u5668\u4e0a\uff0c\u5982Apache\u3001Nginx\u3001Gunicorn\u7b49\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Gunicorn<\/strong>\uff1aGunicorn\u662f\u4e00\u4e2aPython WSGI HTTP\u670d\u52a1\u5668\uff0c\u9002\u5408\u4e8eDjango\u548cFlask\u5e94\u7528\u7684\u90e8\u7f72\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Nginx<\/strong>\uff1aNginx\u53ef\u4ee5\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u8f6c\u53d1\u8bf7\u6c42\u5230Gunicorn\uff0c\u63d0\u9ad8\u5e94\u7528\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u4f7f\u7528\u4e91\u670d\u52a1<\/li>\n<\/ol>\n<p><p>\u73b0\u4ee3Web\u5e94\u7528\u901a\u5e38\u4f1a\u9009\u62e9\u5c06\u5e94\u7528\u90e8\u7f72\u5728\u4e91\u5e73\u53f0\u4e0a\uff0c\u5982AWS\u3001Heroku\u3001DigitalOcean\u7b49\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>Heroku<\/strong>\uff1aHeroku\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u4e91\u5e73\u53f0\uff0c\u63d0\u4f9b\u7b80\u5355\u7684\u90e8\u7f72\u548c\u6269\u5c55\u670d\u52a1\uff0c\u9002\u5408\u4e8e\u4e2d\u5c0f\u578bWeb\u5e94\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>AWS<\/strong>\uff1aAWS\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u4e91\u670d\u52a1\uff0c\u5982EC2\u3001RDS\u3001S3\u7b49\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5927\u89c4\u6a21\u5e94\u7528\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u516d\u3001\u4f18\u5316\u548c\u6269\u5c55<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8Web\u5e94\u7528\u7684\u6027\u80fd\u548c\u53ef\u6269\u5c55\u6027\uff0c\u5f00\u53d1\u8005\u9700\u8981\u8fdb\u884c\u4f18\u5316\u548c\u6269\u5c55\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6027\u80fd\u4f18\u5316<\/li>\n<\/ol>\n<p><p>\u6027\u80fd\u4f18\u5316\u662f\u63d0\u9ad8Web\u5e94\u7528\u54cd\u5e94\u901f\u5ea6\u548c\u5904\u7406\u80fd\u529b\u7684\u91cd\u8981\u624b\u6bb5\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>\u7f13\u5b58<\/strong>\uff1a\u901a\u8fc7\u7f13\u5b58\u5e38\u7528\u6570\u636e\u548c\u9875\u9762\uff0c\u53ef\u4ee5\u51cf\u5c11\u670d\u52a1\u5668\u8d1f\u8f7d\uff0c\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>CDN<\/strong>\uff1a\u4f7f\u7528\u5185\u5bb9\u5206\u53d1\u7f51\u7edc\uff08CDN\uff09\u53ef\u4ee5\u52a0\u901f\u9759\u6001\u8d44\u6e90\u7684\u52a0\u8f7d\uff0c\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u6269\u5c55\u529f\u80fd<\/li>\n<\/ol>\n<p><p>\u968f\u7740\u5e94\u7528\u7684\u53d1\u5c55\uff0c\u5f00\u53d1\u8005\u53ef\u80fd\u9700\u8981\u6dfb\u52a0\u65b0\u7684\u529f\u80fd\u548c\u7279\u6027\u3002<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong>RESTful API<\/strong>\uff1a\u901a\u8fc7\u63d0\u4f9bRESTful API\uff0c\u5e94\u7528\u53ef\u4ee5\u4e0e\u5176\u4ed6\u7cfb\u7edf\u548c\u670d\u52a1\u8fdb\u884c\u96c6\u6210\u548c\u4ea4\u4e92\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9e\u65f6\u529f\u80fd<\/strong>\uff1a\u901a\u8fc7WebSocket\u6216\u7b2c\u4e09\u65b9\u670d\u52a1\uff0c\u5b9e\u73b0\u5b9e\u65f6\u901a\u4fe1\u548c\u6570\u636e\u66f4\u65b0\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u603b\u7ed3\uff0c\u4f7f\u7528Python\u7f16\u5199\u7f51\u9875\u662f\u4e00\u9879\u591a\u65b9\u9762\u7684\u4efb\u52a1\uff0c\u9700\u8981\u638c\u63e1Web\u6846\u67b6\u3001\u670d\u52a1\u5668\u7aef\u7f16\u7a0b\u3001\u6570\u636e\u5e93\u96c6\u6210\u3001\u7528\u6237\u8ba4\u8bc1\u3001\u90e8\u7f72\u4ee5\u53ca\u6027\u80fd\u4f18\u5316\u7b49\u591a\u4e2a\u65b9\u9762\u7684\u77e5\u8bc6\u548c\u6280\u80fd\u3002\u901a\u8fc7\u5408\u7406\u5730\u9009\u62e9\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5feb\u901f\u6784\u5efa\u51fa\u529f\u80fd\u5f3a\u5927\u3001\u6027\u80fd\u4f18\u5f02\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5f00\u59cb\u4f7f\u7528Python\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u7f51\u9875\uff1f<\/strong><br \/>\u8981\u5f00\u59cb\u4f7f\u7528Python\u521b\u5efa\u7f51\u9875\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528Flask\u6216Django\u7b49\u6846\u67b6\u3002Flask\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u6846\u67b6\uff0c\u9002\u5408\u5c0f\u578b\u9879\u76ee\uff0c\u800cDjango\u662f\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6\uff0c\u9002\u5408\u5927\u578b\u5e94\u7528\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u6240\u9700\u7684\u5e93\uff0c\u521b\u5efa\u9879\u76ee\u76ee\u5f55\uff0c\u5e76\u4f7f\u7528Python\u7f16\u5199\u4ee3\u7801\u6765\u5b9a\u4e49\u8def\u7531\u548c\u89c6\u56fe\u3002\u521b\u5efaHTML\u6a21\u677f\u53ef\u4ee5\u4f7f\u7528Jinja2\u7b49\u6a21\u677f\u5f15\u64ce\uff0c\u4ee5\u4fbf\u5c06\u52a8\u6001\u5185\u5bb9\u5d4c\u5165\u5230\u7f51\u9875\u4e2d\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u7f16\u5199\u7f51\u9875\u65f6\uff0c\u5982\u4f55\u5904\u7406\u7528\u6237\u8f93\u5165\uff1f<\/strong><br \/>\u5904\u7406\u7528\u6237\u8f93\u5165\u901a\u5e38\u6d89\u53ca\u8868\u5355\u7684\u4f7f\u7528\u3002\u5728Flask\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>request<\/code>\u5bf9\u8c61\u6765\u83b7\u53d6\u8868\u5355\u6570\u636e\u3002Django\u5219\u63d0\u4f9b\u4e86\u66f4\u4e3a\u5b8c\u6574\u7684\u8868\u5355\u5904\u7406\u673a\u5236\uff0c\u53ef\u4ee5\u4f7f\u7528<code>forms<\/code>\u6a21\u5757\u6765\u8f7b\u677e\u521b\u5efa\u548c\u9a8c\u8bc1\u8868\u5355\u3002\u786e\u4fdd\u5728\u5904\u7406\u7528\u6237\u8f93\u5165\u65f6\u8fdb\u884c\u9002\u5f53\u7684\u9a8c\u8bc1\u548c\u6e05\u7406\uff0c\u4ee5\u9632\u6b62\u5b89\u5168\u6f0f\u6d1e\uff0c\u5982SQL\u6ce8\u5165\u6216\u8de8\u7ad9\u811a\u672c\u653b\u51fb\uff08XSS\uff09\u3002<\/p>\n<p><strong>Python\u7f51\u9875\u5f00\u53d1\u4e2d\u5982\u4f55\u5b9e\u73b0\u6570\u636e\u5e93\u8fde\u63a5\uff1f<\/strong><br \/>\u5728Python\u7f51\u9875\u5f00\u53d1\u4e2d\uff0c\u8fde\u63a5\u6570\u636e\u5e93\u901a\u5e38\u901a\u8fc7ORM\uff08\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\uff09\u6846\u67b6\u6765\u5b9e\u73b0\u3002Django\u81ea\u5e26ORM\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u3002Flask\u5219\u53ef\u4ee5\u4e0eSQLAlchemy\u7b49\u5e93\u7ed3\u5408\u4f7f\u7528\u3002\u65e0\u8bba\u60a8\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u786e\u4fdd\u5728\u9879\u76ee\u4e2d\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u5b9a\u4e49\u6570\u636e\u6a21\u578b\uff0c\u5e76\u4f7f\u7528\u76f8\u5173\u67e5\u8be2\u65b9\u6cd5\u6765\u6267\u884c\u589e\u3001\u5220\u3001\u6539\u3001\u67e5\u7b49\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Python\u7f16\u5199\u7f51\u9875\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0\uff0c\u4e3b\u8981\u5305\u62ec\u4f7f\u7528Web\u6846\u67b6\u3001\u7f16\u5199\u670d\u52a1\u5668\u7aef\u4ee3\u7801\u3001\u96c6\u6210\u6570\u636e\u5e93\u7b49\u51e0\u79cd\u65b9\u5f0f [&hellip;]","protected":false},"author":3,"featured_media":979681,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979671"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=979671"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979671\/revisions"}],"predecessor-version":[{"id":979683,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/979671\/revisions\/979683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/979681"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=979671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=979671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=979671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}