{"id":1042782,"date":"2024-12-31T13:00:19","date_gmt":"2024-12-31T05:00:19","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1042782.html"},"modified":"2024-12-31T13:00:22","modified_gmt":"2024-12-31T05:00:22","slug":"python%e5%a6%82%e4%bd%95%e8%b7%a8%e8%af%ad%e8%a8%80%e8%b0%83%e7%94%a8%e5%87%bd%e6%95%b0%e8%b0%83%e7%94%a8%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1042782.html","title":{"rendered":"python\u5982\u4f55\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u8c03\u7528\u51fd\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/283cd653-8fb6-4052-9b49-e043a97725d4.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5982\u4f55\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u8c03\u7528\u51fd\u6570\" \/><\/p>\n<p><p> <strong>Python\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u5305\u62ec\uff1a\u4f7f\u7528FFI\uff08\u5916\u90e8\u51fd\u6570\u63a5\u53e3\uff09\u3001\u4f7f\u7528C\u6269\u5c55\u3001\u4f7f\u7528Web\u670d\u52a1\u3001\u4f7f\u7528RPC\uff08\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528\uff09\u3001\u4f7f\u7528\u6d88\u606f\u961f\u5217\u3002<\/strong>\u5176\u4e2d\uff0cFFI\u548cC\u6269\u5c55\u6700\u4e3a\u76f4\u63a5\u548c\u9ad8\u6548\u3002FFI\u5141\u8bb8\u76f4\u63a5\u8c03\u7528\u5176\u4ed6\u8bed\u8a00\u7f16\u5199\u7684\u51fd\u6570\uff0c\u800cC\u6269\u5c55\u5219\u5141\u8bb8\u5728Python\u4e2d\u5d4c\u5165C\u4ee3\u7801\u3002\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u51e0\u79cd\u65b9\u6cd5\uff0c\u5e76\u91cd\u70b9\u9610\u8ff0FFI\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001FFI\uff08\u5916\u90e8\u51fd\u6570\u63a5\u53e3\uff09<\/h3>\n<\/p>\n<p><p>FFI\uff08Foreign Function Interface\uff09\u662f\u4e00\u79cd\u5141\u8bb8\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\u8c03\u7528\u53e6\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\u7f16\u5199\u7684\u51fd\u6570\u7684\u673a\u5236\u3002Python\u6709\u51e0\u4e2a\u5e93\u652f\u6301FFI\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u662f<code>ctypes<\/code>\u548c<code>cffi<\/code>\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528ctypes\u5e93<\/h4>\n<\/p>\n<p><p><code>ctypes<\/code>\u662fPython\u6807\u51c6\u5e93\u4e2d\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u5b83\u5141\u8bb8Python\u4ee3\u7801\u8c03\u7528C\u51fd\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528<code>ctypes<\/code>\u8c03\u7528C\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">\/\/ example.c<\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int add(int a, int b) {<\/p>\n<p>    return a + b;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u8bd1\u8fd9\u4e2aC\u6587\u4ef6\u751f\u6210\u5171\u4eab\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">gcc -shared -o example.so -fPIC example.c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5728Python\u4e2d\u8c03\u7528\u8fd9\u4e2aC\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># example.py<\/p>\n<p>import ctypes<\/p>\n<h2><strong>\u52a0\u8f7d\u5171\u4eab\u5e93<\/strong><\/h2>\n<p>example = ctypes.CDLL(&#39;.\/example.so&#39;)<\/p>\n<h2><strong>\u8c03\u7528C\u51fd\u6570<\/strong><\/h2>\n<p>result = example.add(3, 5)<\/p>\n<p>print(f&quot;The result is {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528cffi\u5e93<\/h4>\n<\/p>\n<p><p><code>cffi<\/code>\u662f\u53e6\u4e00\u4e2a\u7528\u4e8eFFI\u7684\u5e93\uff0c\u5b83\u6bd4<code>ctypes<\/code>\u66f4\u7075\u6d3b\u548c\u5f3a\u5927\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528<code>cffi<\/code>\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\u5b89\u88c5<code>cffi<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install cffi<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u5199C\u4ee3\u7801\u5e76\u4fdd\u5b58\u4e3a\u5171\u4eab\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">\/\/ example.c<\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int multiply(int a, int b) {<\/p>\n<p>    return a * b;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u8bd1\u751f\u6210\u5171\u4eab\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">gcc -shared -o example.so -fPIC example.c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5728Python\u4e2d\u4f7f\u7528<code>cffi<\/code>\u8c03\u7528\u8fd9\u4e2aC\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># example.py<\/p>\n<p>from cffi import FFI<\/p>\n<p>ffi = FFI()<\/p>\n<h2><strong>\u5b9a\u4e49C\u51fd\u6570\u7b7e\u540d<\/strong><\/h2>\n<p>ffi.cdef(&quot;&quot;&quot;<\/p>\n<p>    int multiply(int a, int b);<\/p>\n<p>&quot;&quot;&quot;)<\/p>\n<h2><strong>\u52a0\u8f7d\u5171\u4eab\u5e93<\/strong><\/h2>\n<p>example = ffi.dlopen(&#39;.\/example.so&#39;)<\/p>\n<h2><strong>\u8c03\u7528C\u51fd\u6570<\/strong><\/h2>\n<p>result = example.multiply(3, 5)<\/p>\n<p>print(f&quot;The result is {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528C\u6269\u5c55<\/h3>\n<\/p>\n<p><p>Python\u5141\u8bb8\u7f16\u5199C\u6269\u5c55\u6a21\u5757\uff0c\u8fd9\u4e9b\u6a21\u5757\u53ef\u4ee5\u76f4\u63a5\u5728Python\u4e2d\u5bfc\u5165\u548c\u4f7f\u7528\u3002\u8fd9\u79cd\u65b9\u6cd5\u901a\u5e38\u7528\u4e8e\u9700\u8981\u9ad8\u6027\u80fd\u548c\u4f4e\u7ea7\u522b\u63a7\u5236\u7684\u573a\u666f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><p>\u7f16\u5199C\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">\/\/ example.c<\/p>\n<p>#include &lt;Python.h&gt;<\/p>\n<p>static PyObject* py_add(PyObject* self, PyObject* args) {<\/p>\n<p>    int a, b;<\/p>\n<p>    if (!PyArg_ParseTuple(args, &quot;ii&quot;, &amp;a, &amp;b)) {<\/p>\n<p>        return NULL;<\/p>\n<p>    }<\/p>\n<p>    return PyLong_FromLong(a + b);<\/p>\n<p>}<\/p>\n<p>static PyMethodDef ExampleMethods[] = {<\/p>\n<p>    {&quot;add&quot;, py_add, METH_VARARGS, &quot;Add two numbers&quot;},<\/p>\n<p>    {NULL, NULL, 0, NULL}<\/p>\n<p>};<\/p>\n<p>static struct PyModuleDef examplemodule = {<\/p>\n<p>    PyModuleDef_HEAD_INIT,<\/p>\n<p>    &quot;example&quot;,<\/p>\n<p>    NULL,<\/p>\n<p>    -1,<\/p>\n<p>    ExampleMethods<\/p>\n<p>};<\/p>\n<p>PyMODINIT_FUNC PyInit_example(void) {<\/p>\n<p>    return PyModule_Create(&amp;examplemodule);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u5199<code>setup.py<\/code>\u8fdb\u884c\u7f16\u8bd1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># setup.py<\/p>\n<p>from distutils.core import setup, Extension<\/p>\n<p>module = Extension(&#39;example&#39;, sources=[&#39;example.c&#39;])<\/p>\n<p>setup(name=&#39;example&#39;,<\/p>\n<p>      version=&#39;1.0&#39;,<\/p>\n<p>      description=&#39;Python C extension example&#39;,<\/p>\n<p>      ext_modules=[module])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u7f16\u8bd1\u5e76\u5b89\u88c5\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py build<\/p>\n<p>python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728Python\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import example<\/p>\n<p>result = example.add(3, 5)<\/p>\n<p>print(f&quot;The result is {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Web\u670d\u52a1<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u521b\u5efaWeb\u670d\u52a1\uff0c\u53ef\u4ee5\u8ba9\u4e0d\u540c\u7f16\u7a0b\u8bed\u8a00\u4e4b\u95f4\u901a\u8fc7HTTP\u8fdb\u884c\u901a\u4fe1\u3002\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\u8bed\u8a00\u65e0\u5173\uff0c\u7f3a\u70b9\u662f\u6027\u80fd\u76f8\u5bf9\u8f83\u4f4e\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\u4f7f\u7528Flask\u521b\u5efa\u4e00\u4e2aPython Web\u670d\u52a1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># server.py<\/p>\n<p>from flask import Flask, request, jsonify<\/p>\n<p>app = Flask(__name__)<\/p>\n<p>@app.route(&#39;\/add&#39;, methods=[&#39;GET&#39;])<\/p>\n<p>def add():<\/p>\n<p>    a = int(request.args.get(&#39;a&#39;))<\/p>\n<p>    b = int(request.args.get(&#39;b&#39;))<\/p>\n<p>    return jsonify(result=a + b)<\/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(port=5000)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u53e6\u4e00\u4e2a\u8bed\u8a00\uff08\u4f8b\u5982JavaScript\uff09\u4e2d\u8c03\u7528\u8fd9\u4e2aWeb\u670d\u52a1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-javascript\">\/\/ client.js<\/p>\n<p>const fetch = require(&#39;node-fetch&#39;);<\/p>\n<p>async function add(a, b) {<\/p>\n<p>    const response = await fetch(`http:\/\/localhost:5000\/add?a=${a}&amp;b=${b}`);<\/p>\n<p>    const data = await response.json();<\/p>\n<p>    console.log(`The result is ${data.result}`);<\/p>\n<p>}<\/p>\n<p>add(3, 5);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528RPC\uff08\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528\uff09<\/h3>\n<\/p>\n<p><p>RPC\u662f\u4e00\u79cd\u8ba9\u7a0b\u5e8f\u53ef\u4ee5\u8c03\u7528\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7684\u51fd\u6570\u7684\u65b9\u6cd5\u3002Python\u6709\u591a\u4e2a\u5e93\u652f\u6301RPC\uff0c\u5176\u4e2d\u6700\u5e38\u7528\u7684\u662f<code>xmlrpc<\/code>\u548c<code>gRPC<\/code>\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528<code>xmlrpc<\/code>\u7684\u7b80\u5355\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\u521b\u5efa\u4e00\u4e2aXML-RPC\u670d\u52a1\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># server.py<\/p>\n<p>from xmlrpc.server import SimpleXMLRPCServer<\/p>\n<p>def add(a, b):<\/p>\n<p>    return a + b<\/p>\n<p>server = SimpleXMLRPCServer((&#39;localhost&#39;, 9000))<\/p>\n<p>server.register_function(add, &#39;add&#39;)<\/p>\n<p>server.serve_forever()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u5ba2\u6237\u7aef\u8c03\u7528\u8fd9\u4e2a\u8fdc\u7a0b\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># client.py<\/p>\n<p>import xmlrpc.client<\/p>\n<p>proxy = xmlrpc.client.ServerProxy(&#39;http:\/\/localhost:9000\/&#39;)<\/p>\n<p>result = proxy.add(3, 5)<\/p>\n<p>print(f&quot;The result is {result}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u4f7f\u7528\u6d88\u606f\u961f\u5217<\/h3>\n<\/p>\n<p><p>\u6d88\u606f\u961f\u5217\u662f\u4e00\u79cd\u901a\u8fc7\u6d88\u606f\u4f20\u9012\u8fdb\u884c\u901a\u4fe1\u7684\u65b9\u6cd5\u3002\u5e38\u89c1\u7684\u6d88\u606f\u961f\u5217\u7cfb\u7edf\u5305\u62ecRabbitMQ\u3001Kafka\u548cZeroMQ\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528RabbitMQ\u7684\u7b80\u5355\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\u5b89\u88c5RabbitMQ\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pika<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u5199\u751f\u4ea7\u8005\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># producer.py<\/p>\n<p>import pika<\/p>\n<p>connection = pika.BlockingConnection(pika.ConnectionParameters(&#39;localhost&#39;))<\/p>\n<p>channel = connection.channel()<\/p>\n<p>channel.queue_declare(queue=&#39;task_queue&#39;, durable=True)<\/p>\n<p>def add(a, b):<\/p>\n<p>    return a + b<\/p>\n<p>message = f&quot;{3},{5}&quot;<\/p>\n<p>channel.basic_publish(exchange=&#39;&#39;,<\/p>\n<p>                      routing_key=&#39;task_queue&#39;,<\/p>\n<p>                      body=message,<\/p>\n<p>                      properties=pika.BasicProperties(<\/p>\n<p>                          delivery_mode=2,  # make message persistent<\/p>\n<p>                      ))<\/p>\n<p>print(&quot; [x] Sent &#39;3,5&#39;&quot;)<\/p>\n<p>connection.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7f16\u5199\u6d88\u8d39\u8005\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># consumer.py<\/p>\n<p>import pika<\/p>\n<p>connection = pika.BlockingConnection(pika.ConnectionParameters(&#39;localhost&#39;))<\/p>\n<p>channel = connection.channel()<\/p>\n<p>channel.queue_declare(queue=&#39;task_queue&#39;, durable=True)<\/p>\n<p>def callback(ch, method, properties, body):<\/p>\n<p>    a, b = map(int, body.decode().split(&#39;,&#39;))<\/p>\n<p>    result = add(a, b)<\/p>\n<p>    print(f&quot;The result is {result}&quot;)<\/p>\n<p>    ch.basic_ack(delivery_tag=method.delivery_tag)<\/p>\n<p>channel.basic_consume(queue=&#39;task_queue&#39;, on_message_callback=callback)<\/p>\n<p>print(&#39; [*] Waiting for messages. To exit press CTRL+C&#39;)<\/p>\n<p>channel.start_consuming()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u4e94\u79cd\u65b9\u6cd5\u5c55\u793a\u4e86\u5982\u4f55\u5728Python\u4e2d\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\uff0c\u9009\u62e9\u5177\u4f53\u65b9\u6cd5\u5e94\u6839\u636e\u5e94\u7528\u573a\u666f\u548c\u6027\u80fd\u9700\u6c42\u51b3\u5b9a\u3002\u901a\u8fc7FFI\u548cC\u6269\u5c55\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u6548\u7684\u8de8\u8bed\u8a00\u8c03\u7528\uff0c\u800cWeb\u670d\u52a1\u3001RPC\u548c\u6d88\u606f\u961f\u5217\u5219\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u89e3\u51b3\u65b9\u6848\u3002\u5e0c\u671b\u672c\u6587\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528Python\u8fdb\u884c\u8de8\u8bed\u8a00\u51fd\u6570\u8c03\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8c03\u7528\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u7684\u51fd\u6570\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u8c03\u7528\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u7684\u51fd\u6570\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Python\u7684ctypes\u5e93\u53ef\u4ee5\u52a0\u8f7dC\u8bed\u8a00\u7f16\u5199\u7684\u52a8\u6001\u94fe\u63a5\u5e93\uff08DLL\uff09\u6216\u5171\u4eab\u5bf9\u8c61\uff08.so\u6587\u4ef6\uff09\uff0c\u5e76\u76f4\u63a5\u8c03\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002\u6b64\u5916\uff0c\u4f7f\u7528Cython\u6216SWIG\u7b49\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06C\/C++\u4ee3\u7801\u4e0ePython\u96c6\u6210\uff0c\u5141\u8bb8\u5728Python\u4e2d\u8c03\u7528\u590d\u6742\u7684C\/C++\u51fd\u6570\u3002<\/p>\n<p><strong>Python\u4e0eJava\u4e4b\u95f4\u5982\u4f55\u8fdb\u884c\u51fd\u6570\u8c03\u7528\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u8c03\u7528Java\u51fd\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528JPype\u6216Py4J\u7b49\u5e93\u3002JPype\u5141\u8bb8Python\u4ee3\u7801\u4e0eJava\u865a\u62df\u673a\uff08JVM\uff09\u8fdb\u884c\u4ea4\u4e92\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528Java\u7c7b\u548c\u65b9\u6cd5\u3002Py4J\u5219\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u8ba9Python\u7a0b\u5e8f\u4e0eJava\u7a0b\u5e8f\u8fdb\u884c\u901a\u4fe1\uff0c\u4ece\u800c\u5b9e\u73b0\u8de8\u8bed\u8a00\u8c03\u7528\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u4f7f\u7528.NET\u8bed\u8a00\u7684\u51fd\u6570\uff1f<\/strong><br \/>\u5bf9\u4e8e\u9700\u8981\u8c03\u7528.NET\u8bed\u8a00\uff08\u5982C#\uff09\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528Python for .NET\uff08pythonnet\uff09\u5e93\u3002\u8fd9\u4e2a\u5e93\u4f7f\u5f97Python\u80fd\u591f\u4e0e.NET\u6846\u67b6\u4e2d\u7684\u7c7b\u548c\u51fd\u6570\u8fdb\u884c\u4ea4\u4e92\u3002\u7528\u6237\u53ea\u9700\u5b89\u88c5pythonnet\uff0c\u5e76\u5728Python\u811a\u672c\u4e2d\u5bfc\u5165.NET\u7a0b\u5e8f\u96c6\uff0c\u5373\u53ef\u8c03\u7528\u5176\u4e2d\u7684\u65b9\u6cd5\u548c\u5c5e\u6027\u3002<\/p>\n<p><strong>\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u65f6\uff0c\u9700\u8981\u7279\u522b\u6ce8\u610f\u6570\u636e\u7c7b\u578b\u7684\u517c\u5bb9\u6027\u3002\u4f8b\u5982\uff0c\u4e0d\u540c\u8bed\u8a00\u5bf9\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u548c\u5bf9\u8c61\u7684\u5904\u7406\u65b9\u5f0f\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff0c\u786e\u4fdd\u6570\u636e\u5728\u4f20\u9012\u8fc7\u7a0b\u4e2d\u6b63\u786e\u8f6c\u6362\u81f3\u5173\u91cd\u8981\u3002\u6b64\u5916\uff0c\u9519\u8bef\u5904\u7406\u548c\u5f02\u5e38\u7ba1\u7406\u4e5f\u9700\u8981\u7279\u522b\u5173\u6ce8\uff0c\u4ee5\u4fbf\u5728\u8c03\u7528\u8fc7\u7a0b\u4e2d\u53ca\u65f6\u6355\u83b7\u5e76\u5904\u7406\u6f5c\u5728\u7684\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8de8\u8bed\u8a00\u8c03\u7528\u51fd\u6570\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u5305\u62ec\uff1a\u4f7f\u7528FFI\uff08\u5916\u90e8\u51fd\u6570\u63a5\u53e3\uff09\u3001\u4f7f\u7528C\u6269\u5c55\u3001\u4f7f\u7528Web\u670d\u52a1\u3001\u4f7f [&hellip;]","protected":false},"author":3,"featured_media":1042790,"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\/1042782"}],"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=1042782"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1042782\/revisions"}],"predecessor-version":[{"id":1042794,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1042782\/revisions\/1042794"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1042790"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1042782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1042782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1042782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}