{"id":939347,"date":"2024-12-26T20:33:09","date_gmt":"2024-12-26T12:33:09","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/939347.html"},"modified":"2024-12-26T20:33:11","modified_gmt":"2024-12-26T12:33:11","slug":"python-%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85myqr","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/939347.html","title":{"rendered":"Python \u5982\u4f55\u5b89\u88c5myqr"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074422\/d2470330-ff02-4a6b-8210-6f05347b5d46.webp\" alt=\"Python \u5982\u4f55\u5b89\u88c5myqr\" \/><\/p>\n<p><p> <strong>\u8981\u5728Python\u4e2d\u5b89\u88c5myqr\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\u3001\u786e\u4fddPython\u548cpip\u7248\u672c\u517c\u5bb9\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u4f9d\u8d56\u3002<\/strong>\u5176\u4e2d\uff0c\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\u662f\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u3002\u4f7f\u7528<code>pip install myqr<\/code>\u547d\u4ee4\u5373\u53ef\u5feb\u901f\u5b89\u88c5myqr\u5e93\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e00\u4e2a\u6b65\u9aa4\u548c\u6ce8\u610f\u4e8b\u9879\uff0c\u4ee5\u786e\u4fdd\u60a8\u53ef\u4ee5\u987a\u5229\u5730\u5b89\u88c5\u548c\u4f7f\u7528myqr\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528PIP\u8fdb\u884c\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0cpip\u662f\u6700\u5e38\u7528\u7684\u5305\u7ba1\u7406\u5de5\u5177\u3002\u901a\u8fc7pip\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5\u3001\u66f4\u65b0\u6216\u5378\u8f7dPython\u5305\u3002\u5b89\u88c5myqr\u7684\u6b65\u9aa4\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5728\u547d\u4ee4\u884c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install myqr<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u81ea\u52a8\u4ecePython Package Index\uff08PyPI\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5myqr\u5e93\u53ca\u5176\u6240\u6709\u4f9d\u8d56\u9879\u3002\u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u51e0\u79d2\u949f\u5230\u51e0\u5206\u949f\uff0c\u5177\u4f53\u65f6\u95f4\u53d6\u51b3\u4e8e\u60a8\u7684\u7f51\u7edc\u901f\u5ea6\u548c\u8ba1\u7b97\u673a\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u786e\u4fddPython\u548cPIP\u7248\u672c\u517c\u5bb9<\/p>\n<\/p>\n<p><p>\u5b89\u88c5myqr\u4e4b\u524d\uff0c\u786e\u4fdd\u60a8\u7684Python\u548cpip\u7248\u672c\u662f\u517c\u5bb9\u7684\u3002myqr\u652f\u6301Python 3.x\u7248\u672c\uff0c\u56e0\u6b64\u5efa\u8bae\u5b89\u88c5Python 3.6\u53ca\u4ee5\u4e0a\u7248\u672c\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u786e\u4fddpip\u662f\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u66f4\u65b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u65e7\u7248\u672c\u7684Python\u6216pip\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u65e0\u6cd5\u5b89\u88c5\u6216\u4f7f\u7528myqr\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u4e0a\uff0c\u5b89\u88c5Python\u540e\u53ef\u80fd\u9700\u8981\u624b\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u786e\u4fddPython\u548cpip\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u88ab\u6b63\u786e\u8bc6\u522b\u3002\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\uff0c\u9009\u62e9\u201c\u9ad8\u7ea7\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\u627e\u5230\u201cPath\u201d\u53d8\u91cf\uff0c\u53cc\u51fb\u8fdb\u884c\u7f16\u8f91\u3002<\/li>\n<li>\u5c06Python\u5b89\u88c5\u76ee\u5f55\u548cScripts\u76ee\u5f55\u6dfb\u52a0\u5230Path\u53d8\u91cf\u4e2d\u3002\u4f8b\u5982\uff0c<code>C:\\Python39<\/code>\u548c<code>C:\\Python39\\Scripts<\/code>\u3002<\/li>\n<\/ol>\n<p><p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u542f\u52a8\u547d\u4ee4\u884c\u7a97\u53e3\u4ee5\u751f\u6548\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u4f9d\u8d56<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\uff0c\u5efa\u8bae\u4f7f\u7528Python\u7684\u865a\u62df\u73af\u5883\u3002\u865a\u62df\u73af\u5883\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u786e\u4fdd\u9879\u76ee\u4e4b\u95f4\u7684\u76f8\u4e92\u9694\u79bb\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u548c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\"># \u521b\u5efa\u865a\u62df\u73af\u5883<\/p>\n<p>python -m venv my_project_env<\/p>\n<h2><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff08Windows\uff09<\/strong><\/h2>\n<p>my_project_env\\Scripts\\activate<\/p>\n<h2><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff08macOS\u548cLinux\uff09<\/strong><\/h2>\n<p>source my_project_env\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5myqr\uff0c\u5373\u53ef\u786e\u4fddmyqr\u5e93\u4ec5\u5bf9\u5f53\u524d\u9879\u76ee\u53ef\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1myqr\u5e93\u662f\u5426\u6210\u529f\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">python -c &quot;import myqr; print(myqr.__version__)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u547d\u4ee4\u6267\u884c\u6ca1\u6709\u62a5\u9519\u5e76\u8f93\u51famyqr\u7684\u7248\u672c\u53f7\uff0c\u5219\u8868\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5931\u8d25\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u9519\u8bef\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\uff0c\u786e\u4fdd\u53ef\u4ee5\u8bbf\u95eePyPI\u3002\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install myqr -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u63d0\u793a\u6743\u9650\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u884c\uff08Windows\uff09\u6216\u5728\u547d\u4ee4\u524d\u6dfb\u52a0<code>sudo<\/code>\uff08macOS\u548cLinux\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u51b2\u7a81\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u5b58\u5728\u4f9d\u8d56\u51b2\u7a81\uff0c\u8bf7\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u9694\u79bb\u9879\u76ee\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u4f7f\u7528MYQR\u5e93\u751f\u6210\u4e8c\u7ef4\u7801<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528myqr\u5e93\u751f\u6210\u4e8c\u7ef4\u7801\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from MyQR import myqr<\/p>\n<h2><strong>\u751f\u6210\u7b80\u5355\u7684\u4e8c\u7ef4\u7801<\/strong><\/h2>\n<p>myqr.run(<\/p>\n<p>    words=&#39;https:\/\/www.example.com&#39;,<\/p>\n<p>    save_name=&#39;example_qr.png&#39;<\/p>\n<p>)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e0a\u8ff0\u4ee3\u7801\u5c06\u751f\u6210\u4e00\u4e2a\u5305\u542b\u6307\u5b9aURL\u7684\u4e8c\u7ef4\u7801\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u4e3a<code>example_qr.png<\/code>\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u516b\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u6210\u529f\u5b89\u88c5\u548c\u4f7f\u7528myqr\u5e93\u6765\u751f\u6210\u4e8c\u7ef4\u7801\u3002\u4f7f\u7528pip\u53ef\u4ee5\u8f7b\u677e\u5b89\u88c5myqr\u5e93\uff0c\u786e\u4fddPython\u548cpip\u7248\u672c\u517c\u5bb9\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u4ee5\u53ca\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u4f9d\u8d56\uff0c\u53ef\u4ee5\u5e2e\u52a9\u907f\u514d\u5e38\u89c1\u7684\u5b89\u88c5\u95ee\u9898\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u60a8\u5728Python\u7684\u5b66\u4e60\u548c\u4f7f\u7528\u4e2d\u4e00\u5207\u987a\u5229\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u88c5myqr\u5e93\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u5b89\u88c5myqr\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u3002\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>pip install myqr<\/code>\u3002\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u5df2\u6b63\u786e\u8bbe\u7f6e\uff0c\u5e76\u4e14pip\u5df2\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u907f\u514d\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u95ee\u9898\u3002<\/p>\n<p><strong>\u5b89\u88c5myqr\u540e\u5982\u4f55\u4f7f\u7528\u5b83\u751f\u6210\u4e8c\u7ef4\u7801\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5bfc\u5165myqr\u5e93\u6765\u751f\u6210\u4e8c\u7ef4\u7801\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u751f\u6210\u4e00\u4e2a\u5305\u542b\u7f51\u5740\u7684\u4e8c\u7ef4\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">from myqr import myqr\nmyqr.run(words=&#39;https:\/\/www.example.com&#39;)\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u751f\u6210\u4e8c\u7ef4\u7801\u5e76\u4fdd\u5b58\u4e3a\u56fe\u7247\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u81ea\u5b9a\u4e49\u4e8c\u7ef4\u7801\u7684\u5185\u5bb9\u548c\u5916\u89c2\u3002<\/p>\n<p><strong>\u5982\u679c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u9519\u8bef\uff0c\u5e94\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5728\u5b89\u88c5myqr\u65f6\uff0c\u5982\u679c\u9047\u5230\u9519\u8bef\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u6b65\u9aa4\uff1a  <\/p>\n<ol>\n<li>\u786e\u4fddPython\u548cpip\u5df2\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002  <\/li>\n<li>\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\uff0c\u786e\u4fdd\u53ef\u4ee5\u8bbf\u95eePython\u5305\u7d22\u5f15\uff08PyPI\uff09\u3002  <\/li>\n<li>\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528<code>pip install --upgrade pip<\/code>\u6765\u66f4\u65b0pip\u3002  <\/li>\n<li>\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u53ef\u4ee5\u67e5\u770b\u9519\u8bef\u4fe1\u606f\uff0c\u641c\u7d22\u7279\u5b9a\u7684\u9519\u8bef\u4ee3\u7801\u6216\u4fe1\u606f\uff0c\u4ee5\u627e\u5230\u89e3\u51b3\u65b9\u6848\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Python\u4e2d\u5b89\u88c5myqr\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\u3001\u786e\u4fddPython\u548cpip\u7248\u672c\u517c\u5bb9\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528\u865a [&hellip;]","protected":false},"author":3,"featured_media":939349,"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\/939347"}],"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=939347"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939347\/revisions"}],"predecessor-version":[{"id":939350,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939347\/revisions\/939350"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/939349"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=939347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=939347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=939347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}