{"id":3547,"date":"2023-07-25T11:31:09","date_gmt":"2023-07-25T03:31:09","guid":{"rendered":"http:\/\/cnliutz.ipyingshe.net\/?p=3547"},"modified":"2023-07-25T11:31:11","modified_gmt":"2023-07-25T03:31:11","slug":"%e7%bb%99%e5%9b%be%e7%89%87%e6%b7%bb%e5%8a%a0%e6%96%87%e5%ad%97%ef%bc%88%e6%b0%b4%e5%8d%b0%ef%bc%89%e6%96%b9%e6%b3%95python%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=3547","title":{"rendered":"\u7ed9\u56fe\u7247\u6dfb\u52a0\u6587\u5b57\uff08\u6c34\u5370\uff09\u65b9\u6cd5python\u4ee3\u7801"},"content":{"rendered":"\n<p>\u7d20\u6750\uff1a\u540d\u5355f.xlsx<br>\u5e8f\u53f7 \u6821\u533a \u59d3\u540d \u7535\u8bdd  \u90e8\u95e8 \u804c\u4f4d <br>351 \u4e0a\u6d77\u666e\u9640\u6821\u533a \u66fe\u5fd7\u9e4f 19307130192 \u54a8\u8be2\u90e8 \u54a8\u8be2<br>352 \u676d\u5dde\u897f\u6e56\u6821\u533a \u9648\u6cfd\u7965 19300180069 \u529e\u516c\u5ba4 \u6821\u957f<br>353 \u676d\u5dde\u897f\u6e56\u6821\u533a \u6234\u5b50\u745c 19300180001 \u6559\u5b66\u90e8 \u6559\u5b66\u7ecf\u7406<br>354 \u676d\u5dde\u897f\u6e56\u6821\u533a \u675c\u5fc3\u6021 19300180142 \u54a8\u8be2\u90e8 \u54a8\u8be2\u7ecf\u7406<br>355 \u5317\u4eac\u4e2d\u5173\u6751\u6821\u533a \u845b\u660e\u5764 19300180051 \u529e\u516c\u5ba4 \u6821\u957f<br>356 \u5317\u4eac\u4e2d\u5173\u6751\u6821\u533a \u90ed\u5bb6\u6210 19300180034 \u54a8\u8be2 \u54a8\u8be2\u987e\u95ee<br>357 \u5317\u4eac\u4e2d\u5173\u6751\u6821\u533a \u80e1\u6d77\u8fb0 18307110233 \u6559\u5b66\u90e8 \u6559\u5b66\u7ecf\u7406<br>358 \u77f3\u5bb6\u5e84\u6821\u533a \u848b\u8d85\u6e90 19307130014 \u529e\u516c\u5ba4 \u6821\u957f<br>359 \u77f3\u5bb6\u5e84\u6821\u533a \u91d1\u96cd\u5947 19300180057 \u54a8\u8be2\u90e8 \u54a8\u8be2\u7ecf\u7406<br>360 \u77f3\u5bb6\u5e84\u6821\u533a \u909d \u9e92 19300180102 \u6559\u5b66\u90e8 \u8bb2\u5e08<br>361 \u6df1\u5733\u5b9d\u5b89\u6821\u533a \u674e\u6cfd\u660a 19300180070 \u529e\u516c\u5ba4 \u6821\u957f<br>362 \u6df1\u5733\u5b9d\u5b89\u6821\u533a \u5389 \u8317 19300180127 \u6559\u5b66\u90e8 \u6559\u5b66\u7ecf\u7406<br>363 \u6df1\u5733\u5b9d\u5b89\u6821\u533a \u5415\u6587\u97ec 19300180079 \u54a8\u8be2\u90e8 \u54a8\u8be2\u987e\u95ee<br>364 \u6210\u90fd\u5929\u5e9c\u6821\u533a \u9a6c \u8d6b 19300180067 \u529e\u516c\u5ba4 \u6821\u957f<br>365 \u6210\u90fd\u5929\u5e9c\u6821\u533a \u5b8b\u660e\u5947 19307110261 \u54a8\u8be2\u90e8 \u54a8\u8be2\u7ecf\u7406<br>366 \u6210\u90fd\u5929\u5e9c\u6821\u533a \u5434\u5bb6\u8302 19300180082 \u6559\u5b66\u90e8 \u6559\u5b66\u7ecf\u7406<br>367 \u897f\u5b89\u7891\u6797\u6821\u533a \u5434 \u5f3a 19300180083 \u529e\u516c\u5ba4 \u6821\u957f<br>368 \u897f\u5b89\u7891\u6797\u6821\u533a \u8096\u4e91\u6d0b 19307110356 \u54a8\u8be2\u90e8 \u54a8\u8be2\u987e\u95ee<\/p>\n\n\n\n<p>\u56fe\u7247\u7d20\u6750 src.jpg<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"260\" src=\"http:\/\/cnliutz.ipyingshe.net\/wp-content\/uploads\/2023\/07\/src.jpg\" alt=\"\" class=\"wp-image-3548\" srcset=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2023\/07\/src.jpg 452w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2023\/07\/src-300x173.jpg 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u547d\u4ee4\u884c\u5b89\u88c5\u8fd0\u884c\u9700\u8981\u7684\u4f9d\u8d56\u5305\uff1apip install pillow openpyxl<\/li>\n\n\n\n<li>python\u6e90\u4ee3\u7801\uff1a <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u8fd0\u884c\u73af\u5883\uff1awin11\u3001python 3.11\nfrom PIL import Image, ImageDraw, ImageFont\r\nfrom openpyxl import load_workbook\r\nimport random\r\n\r\n\r\ndef task(username, userinfo):\r\n    image = Image.open(\".\/src.jpg\")\r\n    draw = ImageDraw.Draw(image)\r\n    color = 'black'\r\n    text = str(username)\r\n    size = 34\r\n    font = ImageFont.truetype(r\"C:\\Windows\\Fonts\\STXINWEI.ttf\", size=size)\r\n    text_width = draw.textlength(text, font)\r\n    x = (image.width - text_width) \/ 2\r\n    #x=125\r\n    y = 120\r\n    draw.text((x, y), text, font=font, fill=color)\r\n\r\n    text = str(userinfo)\r\n    size = 10\r\n    font = ImageFont.truetype(r\"C:\\Windows\\Fonts\\STXINWEI.ttf\", size=size)\r\n    text_width = draw.textlength(text, font)\r\n    x = (image.width - text_width) \/ 2\r\n    #x =120\r\n    y = 220\r\n    draw.text((x, y), text, font=font, fill=color)\r\n\r\n    image.save('img\/' + str(userinfo) + '-' + str(username) + '.jpg')\r\n    #image.save('img\/' + str(random.randint(100000, 999999)) + '.jpg')\r\n    #image.show()\r\n\r\n\r\ndef import_data(file):\r\n    workbook = load_workbook(file)\r\n    sheet = workbook.active\r\n    for row in sheet.iter_rows():\r\n        row_data = &#91;cell.value for cell in row]\r\n        print(row_data&#91;2])\r\n        print(row_data&#91;1])\r\n        task(row_data&#91;2], row_data&#91;1])\r\n\r\n\r\nif __name__ == '__main__':\r\n    import_data(r\"E:\\mysite\\home\\f.xlsx\")\r\n    print(\"success\")\r\n\r\n\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"260\" src=\"http:\/\/cnliutz.ipyingshe.net\/wp-content\/uploads\/2023\/07\/\u5317\u4eac\u4e2d\u5173\u6751\u6821\u533a-\u845b\u660e\u5764.jpg\" alt=\"\" class=\"wp-image-3549\" srcset=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2023\/07\/\u5317\u4eac\u4e2d\u5173\u6751\u6821\u533a-\u845b\u660e\u5764.jpg 452w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2023\/07\/\u5317\u4eac\u4e2d\u5173\u6751\u6821\u533a-\u845b\u660e\u5764-300x173.jpg 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><figcaption class=\"wp-element-caption\">\u6548\u679c\u56fe<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7d20\u6750\uff1a\u540d\u5355f.xlsx\u5e8f\u53f7 \u6821\u533a \u59d3\u540d \u7535\u8bdd \u90e8\u95e8 \u804c\u4f4d 351 \u4e0a\u6d77\u666e\u9640\u6821\u533a  <span class=\"readmore\"><a href=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=3547\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10],"tags":[],"class_list":["post-3547","post","type-post","status-publish","format-standard","hentry","category-2","category-python"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3547"}],"version-history":[{"count":1,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3547\/revisions"}],"predecessor-version":[{"id":3550,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3547\/revisions\/3550"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3547"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}