{"id":204616,"date":"2025-05-29T10:18:47","date_gmt":"2025-05-29T02:18:47","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204616\/"},"modified":"2025-05-29T10:18:47","modified_gmt":"2025-05-29T02:18:47","slug":"c-%e8%b0%83%e7%94%a8-python-3-%e7%a8%8b%e5%ba%8f%e6%97%b6%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88-createnowindow-%e8%ae%be%e7%bd%ae%e4%b8%ba-true-%e5%90%8e%e7%9c%8b%e4%b8%8d%e5%88%b0%e8%be%93%e5%87%ba","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204616\/","title":{"rendered":"C# \u8c03\u7528 Python 3 \u7a0b\u5e8f\u65f6\uff0c\u4e3a\u4ec0\u4e48 CreateNoWindow \u8bbe\u7f6e\u4e3a true \u540e\u770b\u4e0d\u5230\u8f93\u51fa\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>C# \u8c03\u7528 Python 3 \u7a0b\u5e8f\u65f6\uff0c\u4e3a\u4ec0\u4e48 CreateNoWindow \u8bbe\u7f6e\u4e3a true \u540e\u770b\u4e0d\u5230\u8f93\u51fa\uff1f<\/h1>\n<p>\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aC# \u8c03\u7528 Python 3 \u7a0b\u5e8f\u65f6\uff0c\u4e3a\u4ec0\u4e48 CreateNoWindow \u8bbe\u7f6e\u4e3a true \u540e\u770b\u4e0d\u5230\u8f93\u51fa\uff1f\u300b<\/span>\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241111\/17313223076731e1c35c133.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5728 c# \u4e2d\u8c03\u7528 python 3 \u7a0b\u5e8f<\/strong><\/p>\n<p>\u5728 c# \u4e2d\u8c03\u7528 python 3 \u7a0b\u5e8f\u65f6\uff0c\u5982\u679c\u8bbe\u7f6e\u4e86 p.startinfo.createnowindow = true\uff0c\u7a0b\u5e8f\u4e0d\u4f1a\u663e\u793a\u4efb\u4f55\u5185\u5bb9\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u907f\u514d\u8bbe\u7f6e createnowindow \u4e3a true\u3002\u5c06\u5176\u8bbe\u7f6e\u4e3a false \u4f1a\u5141\u8bb8 python 3 \u7a0b\u5e8f\u7684\u7a97\u53e3\u663e\u793a\u3002<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u793a\u4f8b\u6f14\u793a\u4e86\u6b63\u786e\u7684\u8c03\u7528\u65b9\u5f0f\uff1a<\/p>\n<pre>using System.Diagnostics;\n\nclass Program\n{\n    static void Main(string[] args)\n    {\n        \/\/ \u521b\u5efa\u4e00\u4e2a Python \u7a0b\u5e8f\u542f\u52a8\u4fe1\u606f\u5bf9\u8c61\n        ProcessStartInfo startInfo = new ProcessStartInfo();\n        startInfo.FileName = @\"C:\\path\\to\\python.exe\";\n        startInfo.Arguments = @\"C:\\path\\to\\python_script.py\";\n        startInfo.CreateNoWindow = false; \/\/ **\u91cd\u8981\uff1a\u4e0d\u8981\u8bbe\u7f6e\u6b64\u9009\u9879\u4e3a true**\n\n        \/\/ \u542f\u52a8 Python 3 \u7a0b\u5e8f\n        Process p = Process.Start(startInfo);\n\n        \/\/ \u7b49\u5f85\u7a0b\u5e8f\u5b8c\u6210\n        p.WaitForExit();\n    }\n}<\/pre>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aC# \u8c03\u7528 Python 3 \u7a0b\u5e8f\u65f6\uff0c\u4e3a\u4ec0\u4e48 CreateNoWindow \u8bbe\u7f6e\u4e3a true \u540e\u770b\u4e0d\u5230\u8f93\u51fa\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C# \u8c03\u7528 Python 3 \u7a0b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204616","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204616"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204616\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}