{"id":46035,"date":"2024-12-01T17:47:19","date_gmt":"2024-12-01T09:47:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/46035\/"},"modified":"2024-12-01T17:47:19","modified_gmt":"2024-12-01T09:47:19","slug":"python3-%e7%a8%8b%e5%ba%8f%e6%89%a7%e8%a1%8c%e6%95%b0%e6%8d%ae%e5%ba%93%e6%93%8d%e4%bd%9c%e6%97%b6%e6%8a%a5%e9%94%99-%e5%a4%84%e7%90%86%e4%b8%ad-%ef%bc%9a%e5%a6%82-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/46035\/","title":{"rendered":"Python3 \u7a0b\u5e8f\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u62a5\u9519 \u201c \u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n<p>\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f <\/p>\n<h1>Python3 \u7a0b\u5e8f\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u62a5\u9519 \u201c<\/p>\n<p>\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n<p>\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f <\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<\/p>\n<p>\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n<p>\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f \u300b\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230 \uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01 <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241123\/17323313826741477633d04.jpg\" class=\"aligncenter\" title=\"Python3 \u7a0b\u5e8f\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u62a5\u9519 \u201c \u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"Python3 \u7a0b\u5e8f\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u62a5\u9519 \u201c \u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f\u63d2\u56fe\" \/>\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n<p>\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f &#8221; \/&gt; <\/p>\n<p><strong>python3 \u7a0b\u5e8f\u62a5\u9519<\/strong><\/p>\n<p>\u5728\u6267\u884c\u4e00\u6bb5\u4e1a\u52a1\u4ee3\u7801\u65f6\uff0c\u51fa\u73b0 \u201c&lt;p&gt;\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&lt;\/p&gt;\u201d \u7684\u9519\u8bef\u63d0\u793a\u3002<\/p>\n<p>\u7ecf\u8fc7\u6392\u67e5\uff0c\u53d1\u73b0\u4ee3\u7801\u4e2d\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u90e8\u5206\u6709\u95ee\u9898\uff0c\u5177\u4f53\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>import requests\nimport time\nimport json\nimport pymysql\n\nmydb = pymysql.connect(\n    host=\"92.68.40.12\", port=3306,\n    user=\"root\",\n    password=\"iss_root\",\n    database=\"dynamic_premium_db\"\n)\nmycursor = mydb.cursor()\n\ndef excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, date_time):\n    sql = \"insert into over_flow_price(straragy_id,city_id,app_name,total_price,over_flow_price,time_stamp)values('%s','%s','%s','%s','%s','%s')\" % (stratagy_id, city_id, app_name, total_price, over_flow_price, date_time)\n    mycursor.execute(sql)  # \u62a5\u9519\u884c<\/pre>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p>\u901a\u8fc7\u4ed4\u7ec6\u5206\u6790\u4ee3\u7801\uff0c\u53d1\u73b0\u4ee3\u7801\u4e2d\u7f3a\u5c11\u5bf9\u6570\u636e\u5e93\u4e8b\u52a1\u7684\u5904\u7406\u3002\u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d\uff0c\u7279\u522b\u662f\u6d89\u53ca\u5230\u591a\u4e2a\u8868\u7684\u64cd\u4f5c\u65f6\uff0c\u9700\u8981\u4f7f\u7528\u4e8b\u52a1\u6765\u4fdd\u8bc1\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<p>\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>def excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, date_time):\n    sql = \"INSERT INTO over_flow_price(straragy_id,city_id,app_name,total_price,over_flow_price,time_stamp)VALUES('%s','%s','%s','%s','%s','%s')\" % (stratagy_id, city_id, app_name, total_price, over_flow_price, date_time)\n    try:\n        mycursor.execute(sql)\n        mydb.commit()  # \u63d0\u4ea4\u4e8b\u52a1\n        print('\u63d2\u5165\u6210\u529f')\n    except Exception as e:\n        mydb.rollback()  # \u56de\u6eda\u4e8b\u52a1\n        print('err: ' + sql)\n        print(e)<\/pre>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aPython3 \u7a0b\u5e8f\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u62a5\u9519 \u201c<\/p>\n<p>\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;<\/p>\n<p>\u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f \u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01 <\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; \u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f Python3 \u7a0b\u5e8f\u6267\u884c\u6570\u636e\u5e93\u64cd\u4f5c\u65f6\u62a5\u9519 \u201c \u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; \u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f \u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765 \u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; \u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f \u300b\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230 \uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01 \u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; \u201d\uff1a\u5982\u4f55\u89e3\u51b3\u6570\u636e\u5e93\u4e8b\u52a1\u95ee\u9898\uff1f &#8221; \/&gt; python3 \u7a0b\u5e8f\u62a5\u9519 \u5728\u6267\u884c\u4e00\u6bb5\u4e1a\u52a1\u4ee3\u7801\u65f6\uff0c\u51fa\u73b0 \u201c&lt;p&gt;\u5904\u7406\u4e2d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&lt;\/p&gt;\u201d \u7684\u9519\u8bef\u63d0\u793a\u3002 \u7ecf\u8fc7\u6392\u67e5\uff0c\u53d1\u73b0\u4ee3\u7801\u4e2d\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u90e8\u5206\u6709\u95ee\u9898\uff0c\u5177\u4f53\u4ee3\u7801\u5982\u4e0b\uff1a import requests import time import json import pymysql mydb = pymysql.connect( host=&#8221;92.68.40.12&#8243;, port=3306, user=&#8221;root&#8221;, password=&#8221;iss_root&#8221;, database=&#8221;dynamic_premium_db&#8221; ) mycursor = mydb.cursor() def excute_sql_db(stratagy_id, city_id, app_name, total_price, over_flow_price, date_time): sql = &#8220;insert into over_flow_price(straragy_id,city_id,app_name,total_price,over_flow_price,time_stamp)values(&#8216;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;,&#8217;%s&#8217;)&#8221; % [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-46035","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/46035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=46035"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/46035\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=46035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=46035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=46035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}