{"id":200,"date":"2024-05-09T16:21:30","date_gmt":"2024-05-09T08:21:30","guid":{"rendered":"http:\/\/www.shifengzhi.asia\/?p=200"},"modified":"2024-05-09T16:21:30","modified_gmt":"2024-05-09T08:21:30","slug":"%e7%88%ac%e5%8f%96tiobe%e7%bc%96%e7%a8%8b%e8%af%ad%e8%a8%80%e6%8e%92%e8%a1%8c%e6%a6%9c%e5%b9%b6%e7%94%9f%e6%88%90%e5%8a%a8%e6%80%81%e5%9b%be","status":"publish","type":"post","link":"https:\/\/boki.shifengzhi.top\/?p=200","title":{"rendered":"\u722c\u53d6Tiobe\u7f16\u7a0b\u8bed\u8a00\u6392\u884c\u699c\u5e76\u751f\u6210\u52a8\u6001\u56fe"},"content":{"rendered":"<h3>\u5148\u770b\u6700\u7ec8\u6548\u679c<\/h3>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/tuchuang.shifengzhi.asia\/picture\/tiobe.gif'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"http:\/\/tuchuang.shifengzhi.asia\/picture\/tiobe.gif\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h3>\u722c\u53d6\u6570\u636e\u5e76\u5b58\u5165CSV<\/h3>\n<p>\u4e0d\u540c\u529f\u80fd\u5206\u6210\u4e24\u4e2a\u6587\u4ef6\u770b\u7684\u6e05\u695a\u70b9\uff0c\u8c03\u8bd5\u4e5f\u65b9\u4fbf\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code>\/\/ Tiobe.py\n\nimport csv\nimport re\nimport requests\n\nurl = &#039;https:\/\/www.tiobe.com\/tiobe-index\/&#039;\nheaders = {\n    &#039;User-Agent&#039;: &#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/124.0.0.0 Safari\/537.36&#039;\n}\n# \u521b\u5efa\u672c\u5730\u6587\u4ef6\nf = open(&#039;Tiobe.csv&#039;, &#039;w&#039;, newline=&#039;&#039;)\n# \u5206\u7c7b\nwriter = csv.DictWriter(f, [&#039;Programming&#039;, &#039;DataPer&#039;, &#039;Data&#039;])\nwriter.writeheader()\nresponse = requests.get(url, headers=headers)\nhtml = response.text\n# \u6b63\u5219\u6e05\u6d17\u6570\u636e\nresult = &#039;&#039;.join(re.findall(r&#039;series: (.*?)}\\);&#039;, html, re.DOTALL))\nresult = re.findall(r&#039;({.*?})&#039;, result, re.DOTALL)\nfor item in result:\n    name = &#039;&#039;.join(re.findall(r&quot;{name : &#039;(.*?)&#039;&quot;, item, re.DOTALL))\n    data = re.findall(r&quot;\\[Date.UTC(.*?)]&quot;, item, re.DOTALL)\n    for i in data:\n        i = i.replace(&#039; &#039;, &#039;&#039;)\n        i = re.sub(r&#039;[()]&#039;, &#039;&#039;, i)\n        value = i.split(&#039;,&#039;)[-1]\n        time_list = i.split(&#039;,&#039;)[:3]\n        time = &quot;&quot;\n        for index, j in enumerate(time_list):\n            if index != 0:\n                if len(j) == 1:\n                    j = &#039;0&#039; + j\n            if index == 0:\n                time += j\n            else:\n                time += &#039;-&#039; + j\n        temp = {\n            &#039;Programming&#039;: name,\n            &#039;DataPer&#039;: value,\n            &#039;Data&#039;: time\n        }\n        writer.writerow(temp)\n# \u5199\u5165\u672c\u5730\u6587\u4ef6\nf.close()<\/code><\/pre>\n<h3>\u8bfb\u53d6CSV\u6587\u4ef6\u5e76\u751f\u6210\u52a8\u6001\u56fe<\/h3>\n<pre><code>\/\/ showTiobe.py\n\nimport plotly.express as px\nimport pandas as pd\n\ndf = pd.read_csv(&#039;Tiobe.csv&#039;)\nfig = px.bar(df,\n             y=&quot;Programming&quot;,\n             x=&quot;DataPer&quot;,\n             animation_frame=&quot;Data&quot;,\n             range_x=[0, df.DataPer.max()],\n             orientation=&#039;h&#039;,\n             text=&#039;DataPer&#039;,\n             color=&quot;Programming&quot;)\n# \u8bbe\u7f6e\u52a8\u753b\u6392\u5e8f\u89c4\u5219\u4e3a DataPer \u5347\u5e8f\nfig.update_layout(barmode=&#039;stack&#039;, yaxis={&#039;categoryorder&#039;: &#039;total ascending&#039;})\n# \u7ed8\u5236\nfig.update_layout(width=700, height=700,\n                  xaxis_showgrid=False,\n                  yaxis_showgrid=False,  # x y \u5411\u7ebf\n                  showlegend=True)  # \u56fe\u4f8b\nfig.update_xaxes(title_text=&quot;TIOBE\u8d8b\u52bf\u56fe&quot;)\nfig.show()<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86\uff0c\u8fd0\u884c\u540e\u4f1a\u81ea\u52a8\u5728\u6d4f\u89c8\u5668\u6253\u5f00\u751f\u6210\u597d\u7684\u52a8\u6001\u56fe<br \/>\n\u6bcf\u6b21\u90fd\u76f4\u63a5\u7ed9\u5b8c\u6574\u4ee3\u7801\u65b9\u4fbf\u4f60\u4eecCV\uff0c\u4e0a\u54ea\u627e\u6211\u8fd9\u4e48\u597d\u7684\u4eba q(\u2267\u25bd\u2266q)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u770b\u6700\u7ec8\u6548\u679c \u722c\u53d6\u6570\u636e\u5e76\u5b58\u5165CSV \u4e0d\u540c\u529f\u80fd\u5206\u6210\u4e24\u4e2a\u6587\u4ef6\u770b\u7684\u6e05\u695a\u70b9\uff0c\u8c03\u8bd5\u4e5f\u65b9\u4fbf\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a \/\/ Tiobe. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[22],"class_list":["post-200","post","type-post","status-publish","format-standard","hentry","category-3","tag-22"],"_links":{"self":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200"}],"version-history":[{"count":1,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":201,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions\/201"}],"wp:attachment":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}