{"id":1158188,"date":"2025-01-13T18:37:34","date_gmt":"2025-01-13T10:37:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1158188.html"},"modified":"2025-01-13T18:37:37","modified_gmt":"2025-01-13T10:37:37","slug":"python%e5%a6%82%e4%bd%95%e4%b8%8b%e8%bd%bditchat%e5%ba%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1158188.html","title":{"rendered":"python\u5982\u4f55\u4e0b\u8f7ditchat\u5e93"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25200225\/9608ddad-519e-4db5-9899-5bfa187bfb3f.webp\" alt=\"python\u5982\u4f55\u4e0b\u8f7ditchat\u5e93\" \/><\/p>\n<p><p> <strong>\u901a\u8fc7pip\u3001\u901a\u8fc7\u6e90\u7801\u3001\u901a\u8fc7Anaconda<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u5728Python\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5itchat\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u51e0\u79cd\u4e0d\u540c\u7684\u65b9\u6cd5\u3002<strong>\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u901a\u8fc7pip\u8fdb\u884c\u5b89\u88c5<\/strong>\uff0c<strong>\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4e0b\u8f7d\u6e90\u7801\u5e76\u624b\u52a8\u5b89\u88c5<\/strong>\uff0c<strong>\u6216\u8005\u901a\u8fc7Anaconda\u8fdb\u884c\u5b89\u88c5<\/strong>\u3002\u4e0b\u9762\u6211\u4eec\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u901a\u8fc7pip\u5b89\u88c5itchat<\/h3>\n<\/p>\n<p><p><strong>pip\u662fPython\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4f7f\u7528pip\u5b89\u88c5itchat\u662f\u6700\u7b80\u5355\u548c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<ol>\n<li><strong>\u786e\u4fdd\u5df2\u5b89\u88c5pip<\/strong>\uff1a\u5927\u591a\u6570Python\u53d1\u884c\u7248\u9ed8\u8ba4\u5305\u542bpip\u3002\u5982\u679c\u6ca1\u6709\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\uff0c\u6216\u8005\u5355\u72ec\u5b89\u88c5pip\u3002<\/li>\n<li><strong>\u4f7f\u7528pip\u5b89\u88c5itchat<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code>pip install itchat<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8fd9\u5c06\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5itchat\u5e93\u53ca\u5176\u6240\u6709\u4f9d\u8d56\u9879\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h3>\u4e8c\u3001\u901a\u8fc7\u6e90\u7801\u5b89\u88c5itchat<\/h3>\n<\/p>\n<p><p><strong>\u6709\u65f6\u4f60\u53ef\u80fd\u9700\u8981\u4ece\u6e90\u7801\u5b89\u88c5itchat\uff0c\u7279\u522b\u662f\u5f53\u4f60\u60f3\u8981\u5b89\u88c5\u7279\u5b9a\u7248\u672c\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u5e93\u7684\u5b9e\u73b0\u7ec6\u8282\u3002<\/strong><\/p>\n<\/p>\n<ol>\n<li><strong>\u4e0b\u8f7d\u6e90\u7801<\/strong>\uff1a\u4f60\u53ef\u4ee5\u4eceGitHub\u6216\u5176\u4ed6\u6e90\u7801\u6258\u7ba1\u5e73\u53f0\u4e0b\u8f7ditchat\u7684\u6e90\u7801\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4eceGitHub\u4e0b\u8f7ditchat\u6e90\u7801\u7684\u4f8b\u5b50\uff1a\n<pre><code>git clone https:\/\/github.com\/littlecodersh\/ItChat.git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u5b89\u88c5\u4f9d\u8d56\u9879<\/strong>\uff1a\u8fdb\u5165\u4e0b\u8f7d\u7684\u6e90\u7801\u76ee\u5f55\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u4f9d\u8d56\u9879\uff1a\n<pre><code>cd ItChat<\/p>\n<p>pip install -r requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u5b89\u88c5itchat<\/strong>\uff1a\u5728\u6e90\u7801\u76ee\u5f55\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5itchat\u5e93\uff1a\n<pre><code>python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u901a\u8fc7Anaconda\u5b89\u88c5itchat<\/h3>\n<\/p>\n<p><p><strong>Anaconda\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u7684Python\u53d1\u884c\u7248\uff0c\u5e26\u6709\u5305\u7ba1\u7406\u5668Conda\u3002\u4f7f\u7528Conda\u5b89\u88c5itchat\u4e5f\u662f\u4e00\u79cd\u65b9\u4fbf\u7684\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<ol>\n<li><strong>\u786e\u4fdd\u5df2\u5b89\u88c5Anaconda<\/strong>\uff1a\u4eceAnaconda\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5Anaconda\u3002<\/li>\n<li><strong>\u4f7f\u7528Conda\u5b89\u88c5itchat<\/strong>\uff1a\u5728Anaconda\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<pre><code>conda install -c conda-forge itchat<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u8fd9\u5c06\u4eceConda-Forge\u901a\u9053\u4e0b\u8f7d\u5e76\u5b89\u88c5itchat\u5e93\u3002<\/li>\n<\/p>\n<\/ol>\n<p><h3>\u56db\u3001\u5b89\u88c5\u540e\u9a8c\u8bc1<\/h3>\n<\/p>\n<p><p><strong>\u65e0\u8bba\u4f60\u4f7f\u7528\u54ea\u79cd\u65b9\u6cd5\u5b89\u88c5itchat\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u90fd\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/strong><\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import itchat<\/p>\n<p>print(&quot;Itchat installed successfully!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\u6d88\u606f\u8f93\u51fa\uff0c\u5219\u8bf4\u660eitchat\u5e93\u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p><strong>\u901a\u8fc7pip\u3001\u901a\u8fc7\u6e90\u7801\u3001\u901a\u8fc7Anaconda<\/strong>\uff0c\u8fd9\u4e09\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u7528\u6765\u5b89\u88c5itchat\u5e93\u3002<strong>\u901a\u8fc7pip\u5b89\u88c5\u6700\u4e3a\u7b80\u5355\u548c\u5e38\u7528<\/strong>\uff0c\u800c<strong>\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\u9002\u7528\u4e8e\u9700\u8981\u7279\u5b9a\u7248\u672c\u6216\u4e86\u89e3\u5b9e\u73b0\u7ec6\u8282\u7684\u60c5\u51b5<\/strong>\uff0c<strong>\u901a\u8fc7Anaconda\u5219\u9002\u7528\u4e8e\u4f7f\u7528\u79d1\u5b66\u8ba1\u7b97\u73af\u5883\u7684\u7528\u6237<\/strong>\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u65b9\u6cd5\uff0c\u53ef\u4ee5\u786e\u4fdd\u4f60\u987a\u5229\u4f7f\u7528itchat\u5e93\u8fdb\u884c\u5fae\u4fe1\u76f8\u5173\u7684\u5f00\u53d1\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001Itchat\u5e93\u7684\u57fa\u672c\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528itchat\u5e93\u8fdb\u884c\u5fae\u4fe1\u76f8\u5173\u7684\u5f00\u53d1\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u672c\u7684\u4f7f\u7528\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u767b\u5f55\u5fae\u4fe1<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import itchat<\/p>\n<p>itchat.auto_login(hotReload=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>auto_login\u51fd\u6570\u4f1a\u5f39\u51fa\u4e00\u4e2a\u4e8c\u7ef4\u7801\uff0c\u626b\u63cf\u4e8c\u7ef4\u7801\u540e\u5373\u53ef\u767b\u5f55\u5fae\u4fe1<\/strong>\u3002\u53c2\u6570<code>hotReload=True<\/code>\u8868\u793a\u5c06\u767b\u5f55\u72b6\u6001\u4fdd\u5b58\u5230\u672c\u5730\uff0c\u4e0b\u6b21\u8fd0\u884c\u65f6\u53ef\u4ee5\u81ea\u52a8\u767b\u5f55\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u53d1\u9001\u6d88\u606f<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">itchat.send(&#39;Hello, filehelper&#39;, toUserName=&#39;filehelper&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u4e0a\u9762\u7684\u4ee3\u7801\u5c06\u6d88\u606f\u201cHello, filehelper\u201d\u53d1\u9001\u5230\u5fae\u4fe1\u52a9\u624b\uff08filehelper\uff09<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u83b7\u53d6\u597d\u53cb\u5217\u8868<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">friends = itchat.get_friends()<\/p>\n<p>for friend in friends:<\/p>\n<p>    print(friend[&#39;NickName&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>get_friends\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u597d\u53cb\u5217\u8868<\/strong>\uff0c\u6bcf\u4e2a\u597d\u53cb\u662f\u4e00\u4e2a\u5b57\u5178\uff0c\u5305\u542b\u591a\u4e2a\u5b57\u6bb5\uff0c\u6bd4\u5982\u6635\u79f0\uff08NickName\uff09\u3001\u5907\u6ce8\u540d\uff08RemarkName\uff09\u7b49\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u63a5\u53d7\u6d88\u606f<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">@itchat.msg_register(itchat.content.TEXT)<\/p>\n<p>def text_reply(msg):<\/p>\n<p>    return msg[&#39;Text&#39;]<\/p>\n<p>itchat.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u88c5\u9970\u5668@itchat.msg_register\u6ce8\u518c\u4e00\u4e2a\u6d88\u606f\u5904\u7406\u51fd\u6570text_reply<\/strong>\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u5728\u6536\u5230\u6587\u672c\u6d88\u606f\u65f6\u88ab\u8c03\u7528\uff0c\u5e76\u8fd4\u56de\u6d88\u606f\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u6df1\u5165\u4f7f\u7528Itchat<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u529f\u80fd\u5916\uff0citchat\u8fd8\u63d0\u4f9b\u4e86\u5f88\u591a\u9ad8\u7ea7\u529f\u80fd\uff0c\u6bd4\u5982\u7fa4\u804a\u7ba1\u7406\u3001\u6587\u4ef6\u4f20\u8f93\u3001\u56fe\u7247\u5904\u7406\u7b49\u3002\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e9b\u9ad8\u7ea7\u4f7f\u7528\u793a\u4f8b\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7fa4\u804a\u7ba1\u7406<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u83b7\u53d6\u6240\u6709\u7fa4\u804a\u5217\u8868<\/p>\n<p>chatrooms = itchat.get_chatrooms()<\/p>\n<p>for chatroom in chatrooms:<\/p>\n<p>    print(chatroom[&#39;NickName&#39;])<\/p>\n<h2><strong>\u5411\u7279\u5b9a\u7fa4\u804a\u53d1\u9001\u6d88\u606f<\/strong><\/h2>\n<p>itchat.send(&#39;Hello, Group!&#39;, toUserName=&#39;@@chatroom_id&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>get_chatrooms\u51fd\u6570\u8fd4\u56de\u6240\u6709\u7fa4\u804a\u5217\u8868<\/strong>\uff0c\u6bcf\u4e2a\u7fa4\u804a\u662f\u4e00\u4e2a\u5b57\u5178\uff0c\u5305\u542b\u591a\u4e2a\u5b57\u6bb5\uff0c\u6bd4\u5982\u7fa4\u804a\u540d\u79f0\uff08NickName\uff09\u3001\u7fa4\u804aID\uff08UserName\uff09\u7b49\u3002<strong>\u53ef\u4ee5\u4f7f\u7528send\u51fd\u6570\u5411\u7279\u5b9a\u7fa4\u804a\u53d1\u9001\u6d88\u606f<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6587\u4ef6\u4f20\u8f93<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\"># \u53d1\u9001\u6587\u4ef6<\/p>\n<p>itchat.send_file(&#39;path\/to\/file&#39;, toUserName=&#39;filehelper&#39;)<\/p>\n<h2><strong>\u53d1\u9001\u56fe\u7247<\/strong><\/h2>\n<p>itchat.send_image(&#39;path\/to\/image&#39;, toUserName=&#39;filehelper&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>send_file\u548csend_image\u51fd\u6570\u7528\u4e8e\u53d1\u9001\u6587\u4ef6\u548c\u56fe\u7247<\/strong>\uff0c\u53c2\u6570\u4e3a\u6587\u4ef6\u8def\u5f84\u548c\u63a5\u6536\u8005\u7684\u7528\u6237\u540d\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u56fe\u7247\u5904\u7406<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<h2><strong>\u83b7\u53d6\u597d\u53cb\u5934\u50cf<\/strong><\/h2>\n<p>head_img = itchat.get_head_img(userName=&#39;friend_user_name&#39;)<\/p>\n<p>with open(&#39;head_img.jpg&#39;, &#39;wb&#39;) as f:<\/p>\n<p>    f.write(head_img)<\/p>\n<h2><strong>\u4f7f\u7528Pillow\u5904\u7406\u5934\u50cf<\/strong><\/h2>\n<p>img = Image.open(&#39;head_img.jpg&#39;)<\/p>\n<p>img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>get_head_img\u51fd\u6570\u8fd4\u56de\u597d\u53cb\u5934\u50cf\u7684\u4e8c\u8fdb\u5236\u6570\u636e<\/strong>\uff0c\u53ef\u4ee5\u5c06\u5176\u4fdd\u5b58\u5230\u672c\u5730\u6587\u4ef6\u3002\u7136\u540e\uff0c<strong>\u53ef\u4ee5\u4f7f\u7528Pillow\u5e93\u5bf9\u5934\u50cf\u8fdb\u884c\u5904\u7406<\/strong>\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u81ea\u52a8\u56de\u590d<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">@itchat.msg_register(itchat.content.TEXT)<\/p>\n<p>def auto_reply(msg):<\/p>\n<p>    reply = &quot;Auto reply: &quot; + msg[&#39;Text&#39;]<\/p>\n<p>    return reply<\/p>\n<p>itchat.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u88c5\u9970\u5668@itchat.msg_register\u6ce8\u518c\u4e00\u4e2a\u81ea\u52a8\u56de\u590d\u51fd\u6570auto_reply<\/strong>\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u5728\u6536\u5230\u6587\u672c\u6d88\u606f\u65f6\u88ab\u8c03\u7528\uff0c\u5e76\u8fd4\u56de\u81ea\u52a8\u56de\u590d\u7684\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001Itchat\u5e93\u7684\u6269\u5c55<\/h3>\n<\/p>\n<p><p>itchat\u5e93\u662f\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u6269\u5c55\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u65b0\u7684\u6d88\u606f\u5904\u7406\u51fd\u6570\u3001\u6269\u5c55\u73b0\u6709\u529f\u80fd\u3001\u4fee\u590dbug\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u6dfb\u52a0\u65b0\u7684\u6d88\u606f\u5904\u7406\u51fd\u6570<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">@itchat.msg_register(itchat.content.PICTURE)<\/p>\n<p>def picture_reply(msg):<\/p>\n<p>    return &#39;Picture received&#39;<\/p>\n<p>itchat.run()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u88c5\u9970\u5668@itchat.msg_register\u6ce8\u518c\u4e00\u4e2a\u56fe\u7247\u6d88\u606f\u5904\u7406\u51fd\u6570picture_reply<\/strong>\uff0c\u8fd9\u4e2a\u51fd\u6570\u4f1a\u5728\u6536\u5230\u56fe\u7247\u6d88\u606f\u65f6\u88ab\u8c03\u7528\uff0c\u5e76\u8fd4\u56de\u201cPicture received\u201d\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u6269\u5c55\u73b0\u6709\u529f\u80fd<\/h4>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c<strong>\u4f60\u53ef\u4ee5\u4e3aitchat\u5e93\u6dfb\u52a0\u65b0\u7684API<\/strong>\uff0c\u6bd4\u5982\u83b7\u53d6\u7fa4\u804a\u6210\u5458\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def get_chatroom_members(chatroom_id):<\/p>\n<p>    return itchat.update_chatroom(chatroom_id, det<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ledMember=True)[&#39;MemberList&#39;]<\/p>\n<p>chatroom_id = &#39;@@chatroom_id&#39;<\/p>\n<p>members = get_chatroom_members(chatroom_id)<\/p>\n<p>for member in members:<\/p>\n<p>    print(member[&#39;NickName&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u901a\u8fc7update_chatroom\u51fd\u6570\u83b7\u53d6\u7fa4\u804a\u7684\u8be6\u7ec6\u4fe1\u606f<\/strong>\uff0c\u5305\u62ec\u7fa4\u804a\u6210\u5458\u5217\u8868\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u4fee\u590dbug<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5728\u4f7f\u7528itchat\u5e93\u65f6\u9047\u5230bug\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u81ea\u5df1\u4fee\u590d\u3002<strong>\u4f60\u53ef\u4ee5\u4eceGitHub\u4e0a\u4e0b\u8f7d\u6e90\u7801\uff0c\u627e\u5230bug\u6240\u5728\u7684\u4ee3\u7801\u5e76\u8fdb\u884c\u4fee\u6539<\/strong>\u3002\u7136\u540e\uff0c<strong>\u53ef\u4ee5\u5c06\u4fee\u6539\u540e\u7684\u4ee3\u7801\u63d0\u4ea4\u5230GitHub\uff0c\u8d21\u732e\u7ed9\u5f00\u6e90\u793e\u533a<\/strong>\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001Itchat\u5e93\u7684\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528itchat\u5e93\u65f6\uff0c<strong>\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9<\/strong>\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u5fae\u4fe1\u767b\u5f55\u9650\u5236<\/strong>\uff1aitchat\u4f7f\u7528\u5fae\u4fe1\u7f51\u9875\u7248\u8fdb\u884c\u767b\u5f55\uff0c\u5fae\u4fe1\u5bf9\u7f51\u9875\u7248\u7684\u767b\u5f55\u6709\u4e00\u5b9a\u9650\u5236\u3002\u5982\u679c\u9891\u7e41\u767b\u5f55\u53ef\u80fd\u4f1a\u88ab\u9650\u5236\u3002<\/li>\n<li><strong>\u9690\u79c1\u95ee\u9898<\/strong>\uff1aitchat\u83b7\u53d6\u4e86\u4f60\u7684\u5fae\u4fe1\u4fe1\u606f\u548c\u597d\u53cb\u5217\u8868\uff0c\u8bf7\u6ce8\u610f\u4fdd\u62a4\u9690\u79c1\uff0c\u4e0d\u8981\u5c06\u767b\u5f55\u4fe1\u606f\u6cc4\u9732\u7ed9\u4ed6\u4eba\u3002<\/li>\n<li><strong>API\u53d8\u66f4<\/strong>\uff1a\u5fae\u4fe1\u7684API\u63a5\u53e3\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u66f4\uff0c\u5bfc\u81f4itchat\u5e93\u90e8\u5206\u529f\u80fd\u5931\u6548\u3002\u8bf7\u53ca\u65f6\u5173\u6ce8itchat\u7684\u66f4\u65b0\u548c\u7ef4\u62a4\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86<strong>\u5728Python\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5itchat\u5e93\u7684\u51e0\u79cd\u65b9\u6cd5<\/strong>\uff0c\u5305\u62ec<strong>\u901a\u8fc7pip\u3001\u901a\u8fc7\u6e90\u7801\u3001\u901a\u8fc7Anaconda<\/strong>\uff0c\u5e76\u4ecb\u7ecd\u4e86<strong>itchat\u5e93\u7684\u57fa\u672c\u4f7f\u7528\u548c\u9ad8\u7ea7\u529f\u80fd<\/strong>\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86<strong>\u5982\u4f55\u6269\u5c55itchat\u5e93<\/strong>\uff0c\u4ee5\u53ca<strong>\u4f7f\u7528itchat\u5e93\u65f6\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879<\/strong>\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u4f7f\u7528itchat\u5e93\u8fdb\u884c\u5fae\u4fe1\u76f8\u5173\u5f00\u53d1\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u73af\u5883\u4e2d\u5b89\u88c5itchat\u5e93\uff1f<\/strong><br \/>\u8981\u5728Python\u73af\u5883\u4e2d\u5b89\u88c5itchat\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>pip install itchat<\/code>\u3002\u786e\u4fdd\u60a8\u7684\u7f51\u7edc\u8fde\u63a5\u6b63\u5e38\uff0c\u4ee5\u4fbf\u987a\u5229\u4e0b\u8f7d\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fAnaconda\u73af\u5883\uff0c\u53ef\u4ee5\u5728Anaconda Prompt\u4e2d\u4f7f\u7528\u76f8\u540c\u7684\u547d\u4ee4\u3002<\/p>\n<p><strong>itchat\u5e93\u662f\u5426\u652f\u6301\u6240\u6709\u7248\u672c\u7684Python\uff1f<\/strong><br \/>itchat\u5e93\u4e3b\u8981\u652f\u6301Python 3.x\u7248\u672c\u3002\u5efa\u8bae\u4f7f\u7528\u6700\u65b0\u7684Python 3\u7248\u672c\uff0c\u4ee5\u786e\u4fdd\u83b7\u5f97\u6700\u4f73\u7684\u517c\u5bb9\u6027\u548c\u6700\u65b0\u7684\u529f\u80fd\u3002\u5982\u679c\u60a8\u6b63\u5728\u4f7f\u7528\u8f83\u65e7\u7684\u7248\u672c\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<p><strong>\u5728\u5b89\u88c5itchat\u540e\u5982\u4f55\u9a8c\u8bc1\u5b83\u662f\u5426\u6210\u529f\u5b89\u88c5\uff1f<\/strong><br \/>\u5b89\u88c5\u6210\u529f\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\u6216\u811a\u672c\u4e2d\u8f93\u5165<code>import itchat<\/code>\u6765\u9a8c\u8bc1\u3002\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4efb\u4f55\u9519\u8bef\u4fe1\u606f\uff0c\u8bf4\u660eitchat\u5e93\u5df2\u6210\u529f\u5b89\u88c5\u3002\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528<code>itchat.__version__<\/code>\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684itchat\u7248\u672c\uff0c\u4ee5\u786e\u8ba4\u5176\u5b8c\u6574\u6027\u548c\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u901a\u8fc7pip\u3001\u901a\u8fc7\u6e90\u7801\u3001\u901a\u8fc7Anaconda \u8981\u5728Python\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5itchat\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u51e0\u79cd\u4e0d\u540c\u7684\u65b9\u6cd5 [&hellip;]","protected":false},"author":3,"featured_media":1158191,"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\/1158188"}],"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=1158188"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1158188\/revisions"}],"predecessor-version":[{"id":1158193,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1158188\/revisions\/1158193"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1158191"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1158188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1158188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1158188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}