{"id":1820,"date":"2021-07-10T14:26:36","date_gmt":"2021-07-10T06:26:36","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=1820"},"modified":"2021-07-10T15:25:35","modified_gmt":"2021-07-10T07:25:35","slug":"python%e7%94%bb%e5%90%8c%e5%bf%83%e5%9c%86%ef%bc%88%e5%ae%9e%e5%bf%83%ef%bc%89","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=1820","title":{"rendered":"Python\u753b\u540c\u5fc3\u5706\uff08\u5b9e\u5fc3\uff09"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#First to install numpy and opencv-python\r\n#pip install nimpy opencv-python\r\nfrom turtle import *\r\nimport numpy as np\r\nimport cv2\r\nimport random\r\n\r\n\r\n#draw_dot()\r\ndef dots(colors,radio):\r\n    color(colors)\r\n    dot(radio)\r\n    \r\ncolors = &#91;\"grey\",\"yellow\",\"green\",\"red\",\"blue\",\"black\",\"pink\",\"white\"]\r\nfor i in range(600,20,-40):\r\n    print(i)\r\n    color(colors&#91;random.randint(0,7)])\r\n    dot(i)\r\n\r\n##==================================================# \r\n##import numpy as np\r\n##import cv2\r\n\rdef main():\r\n\r    # 1.\u521b\u5efa\u767d\u8272\u80cc\u666f\u56fe\u7247\r\n    d = 400\r\n    img = np.ones((d, d, 3), np.uint8) * 255\r\n\r\n    # 2.\u5faa\u73af\u968f\u673a\u7ed8\u5236\u5b9e\u5fc3\u5706\r\n    for i in range(0, 100):\r\n        # \u968f\u673a\u4e2d\u5fc3\u70b9\r\n        center_x = np.random.randint(0, high=d)\r\n        center_y = np.random.randint(0, high=d)\r\n\r\n        # \u968f\u673a\u534a\u5f84\u4e0e\u989c\u8272\r\n        radius = np.random.randint(5, high=d\/5)\r\n        color = np.random.randint(0, high=256, size=(3, )).tolist()\r\n\r        cv2.circle(img, (center_x, center_y), radius, color, -1)\r\n\r\n    # 3.\u663e\u793a\u7ed3\u679c\r\n    cv2.imshow(\"img\", img)\r\n    cv2.waitKey()\r\n    cv2.destroyAllWindows()\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-gallery columns-2 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2021\/07\/\u56ed-1024x576.png\" alt=\"\" data-id=\"1822\" data-full-url=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2021\/07\/\u56ed.png\" data-link=\"http:\/\/cnliutz.uicp.io\/?attachment_id=1822\" class=\"wp-image-1822\" srcset=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed-1024x576.png 1024w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed-300x169.png 300w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed-768x432.png 768w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2021\/07\/\u56ed1-1024x576.png\" alt=\"\" data-id=\"1823\" data-full-url=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2021\/07\/\u56ed1.png\" data-link=\"http:\/\/cnliutz.uicp.io\/?attachment_id=1823\" class=\"wp-image-1823\" srcset=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed1-1024x576.png 1024w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed1-300x169.png 300w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed1-768x432.png 768w, http:\/\/g1n29wqq.ipyingshe.net:5347\/wp-content\/uploads\/2021\/07\/\u56ed1.png 1152w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/li><\/ul><\/figure>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-1820","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/1820","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=1820"}],"version-history":[{"count":4,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/1820\/revisions"}],"predecessor-version":[{"id":1826,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/1820\/revisions\/1826"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1820"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}