{"id":1124527,"date":"2025-01-08T19:42:31","date_gmt":"2025-01-08T11:42:31","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1124527.html"},"modified":"2025-01-08T19:42:34","modified_gmt":"2025-01-08T11:42:34","slug":"python%e5%a6%82%e4%bd%95%e8%b0%83%e7%94%a8%e4%b8%89%e8%a7%92%e5%87%bd%e6%95%b0%e5%85%ac%e5%bc%8f%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1124527.html","title":{"rendered":"python\u5982\u4f55\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u5927\u5168"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25085538\/f897884d-33f9-45dd-acfa-7fef907e072a.webp\" alt=\"python\u5982\u4f55\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u5927\u5168\" \/><\/p>\n<p><p> <strong>Python\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u5927\u5168<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u7f16\u7a0b\u4e2d\uff0c\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u975e\u5e38\u7b80\u5355\u3002<strong>Python\u7684\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e2a\u540d\u4e3a<code>math<\/code>\u7684\u6a21\u5757\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u6240\u6709\u5e38\u7528\u7684\u4e09\u89d2\u51fd\u6570\u516c\u5f0f<\/strong>\u3002\u901a\u8fc7\u4f7f\u7528<code>math<\/code>\u6a21\u5757\uff0c\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u5404\u79cd\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\uff0c\u5982\u6b63\u5f26\u3001\u4f59\u5f26\u3001\u6b63\u5207\u7b49\u3002<strong>\u4f8b\u5982\uff0c\u4f7f\u7528<code>math.sin()<\/code>\u8ba1\u7b97\u6b63\u5f26\u503c\u3001\u4f7f\u7528<code>math.cos()<\/code>\u8ba1\u7b97\u4f59\u5f26\u503c\u3001\u4f7f\u7528<code>math.tan()<\/code>\u8ba1\u7b97\u6b63\u5207\u503c<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Python\u4e2d\u8c03\u7528\u8fd9\u4e9b\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\uff0c\u5e76\u89e3\u91ca\u6bcf\u4e2a\u51fd\u6570\u7684\u5177\u4f53\u7528\u6cd5\u548c\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5bfc\u5165math\u6a21\u5757<\/h2>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u4efb\u4f55\u4e09\u89d2\u51fd\u6570\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u5bfc\u5165Python\u7684<code>math<\/code>\u6a21\u5757\u3002\u8fd9\u4e2a\u6a21\u5757\u5305\u542b\u4e86\u6240\u6709\u57fa\u672c\u7684\u4e09\u89d2\u51fd\u6570\u3001\u6307\u6570\u51fd\u6570\u3001\u5bf9\u6570\u51fd\u6570\u7b49\u3002\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u53ef\u4ee5\u5bfc\u5165<code>math<\/code>\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u8ba1\u7b97\u89d2\u5ea6\u7684\u6b63\u5f26\u503c<\/h2>\n<\/p>\n<p><p>\u6b63\u5f26\u51fd\u6570\u662f\u4e09\u89d2\u51fd\u6570\u4e2d\u6700\u57fa\u672c\u7684\u51fd\u6570\u4e4b\u4e00\u3002\u5b83\u8868\u793a\u4e00\u4e2a\u89d2\u7684\u5bf9\u8fb9\u4e0e\u659c\u8fb9\u7684\u6bd4\u503c\u3002\u4f7f\u7528<code>math.sin()<\/code>\u51fd\u6570\u53ef\u4ee5\u8ba1\u7b97\u4e00\u4e2a\u89d2\u5ea6\u7684\u6b63\u5f26\u503c\u3002\u6ce8\u610f\uff0c<strong><code>math.sin()<\/code>\u51fd\u6570\u7684\u53c2\u6570\u9700\u8981\u662f\u5f27\u5ea6\uff0c\u800c\u4e0d\u662f\u89d2\u5ea6<\/strong>\u3002\u5982\u679c\u4f60\u6709\u89d2\u5ea6\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/strong><\/h2>\n<p>angle_in_degrees = 30<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<h2><strong>\u8ba1\u7b97\u6b63\u5f26\u503c<\/strong><\/h2>\n<p>sin_value = math.sin(angle_in_radians)<\/p>\n<p>print(f&quot;sin(30\u00b0) = {sin_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u8ba1\u7b97\u89d2\u5ea6\u7684\u4f59\u5f26\u503c<\/h2>\n<\/p>\n<p><p>\u4f59\u5f26\u51fd\u6570\u8868\u793a\u4e00\u4e2a\u89d2\u7684\u90bb\u8fb9\u4e0e\u659c\u8fb9\u7684\u6bd4\u503c\u3002\u4f7f\u7528<code>math.cos()<\/code>\u51fd\u6570\u53ef\u4ee5\u8ba1\u7b97\u4e00\u4e2a\u89d2\u5ea6\u7684\u4f59\u5f26\u503c\uff0c\u540c\u6837\u9700\u8981\u4f20\u5165\u5f27\u5ea6\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/strong><\/h2>\n<p>angle_in_degrees = 60<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<h2><strong>\u8ba1\u7b97\u4f59\u5f26\u503c<\/strong><\/h2>\n<p>cos_value = math.cos(angle_in_radians)<\/p>\n<p>print(f&quot;cos(60\u00b0) = {cos_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u8ba1\u7b97\u89d2\u5ea6\u7684\u6b63\u5207\u503c<\/h2>\n<\/p>\n<p><p>\u6b63\u5207\u51fd\u6570\u8868\u793a\u4e00\u4e2a\u89d2\u7684\u5bf9\u8fb9\u4e0e\u90bb\u8fb9\u7684\u6bd4\u503c\u3002\u4f7f\u7528<code>math.tan()<\/code>\u51fd\u6570\u53ef\u4ee5\u8ba1\u7b97\u4e00\u4e2a\u89d2\u5ea6\u7684\u6b63\u5207\u503c\uff0c\u53c2\u6570\u540c\u6837\u9700\u8981\u662f\u5f27\u5ea6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/strong><\/h2>\n<p>angle_in_degrees = 45<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<h2><strong>\u8ba1\u7b97\u6b63\u5207\u503c<\/strong><\/h2>\n<p>tan_value = math.tan(angle_in_radians)<\/p>\n<p>print(f&quot;tan(45\u00b0) = {tan_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e94\u3001\u53cd\u4e09\u89d2\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u4e09\u89d2\u51fd\u6570\uff0c<code>math<\/code>\u6a21\u5757\u8fd8\u63d0\u4f9b\u4e86\u53cd\u4e09\u89d2\u51fd\u6570\uff0c\u7528\u4e8e\u4ece\u6bd4\u503c\u53cd\u63a8\u51fa\u89d2\u5ea6\u3002\u8fd9\u4e9b\u51fd\u6570\u5305\u62ec<code>math.asin()<\/code>\u3001<code>math.acos()<\/code>\u548c<code>math.atan()<\/code>\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u8ba1\u7b97\u53cd\u6b63\u5f26\u503c<\/h3>\n<\/p>\n<p><p>\u53cd\u6b63\u5f26\u51fd\u6570<code>math.asin()<\/code>\u63a5\u53d7\u4e00\u4e2a\u4ecb\u4e8e-1\u52301\u4e4b\u95f4\u7684\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a\u5f27\u5ea6\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u53cd\u6b63\u5f26\u503c<\/strong><\/h2>\n<p>value = 0.5<\/p>\n<p>angle_in_radians = math.asin(value)<\/p>\n<p>angle_in_degrees = math.degrees(angle_in_radians)<\/p>\n<p>print(f&quot;asin(0.5) = {angle_in_degrees}\u00b0&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u8ba1\u7b97\u53cd\u4f59\u5f26\u503c<\/h3>\n<\/p>\n<p><p>\u53cd\u4f59\u5f26\u51fd\u6570<code>math.acos()<\/code>\u4e0e\u53cd\u6b63\u5f26\u51fd\u6570\u7c7b\u4f3c\uff0c\u4e5f\u63a5\u53d7\u4e00\u4e2a\u4ecb\u4e8e-1\u52301\u4e4b\u95f4\u7684\u53c2\u6570\uff0c\u8fd4\u56de\u4e00\u4e2a\u5f27\u5ea6\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u53cd\u4f59\u5f26\u503c<\/strong><\/h2>\n<p>value = 0.5<\/p>\n<p>angle_in_radians = math.acos(value)<\/p>\n<p>angle_in_degrees = math.degrees(angle_in_radians)<\/p>\n<p>print(f&quot;acos(0.5) = {angle_in_degrees}\u00b0&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u8ba1\u7b97\u53cd\u6b63\u5207\u503c<\/h3>\n<\/p>\n<p><p>\u53cd\u6b63\u5207\u51fd\u6570<code>math.atan()<\/code>\u63a5\u53d7\u4efb\u610f\u5b9e\u6570\u503c\uff0c\u8fd4\u56de\u4e00\u4e2a\u5f27\u5ea6\u503c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u53cd\u6b63\u5207\u503c<\/strong><\/h2>\n<p>value = 1<\/p>\n<p>angle_in_radians = math.atan(value)<\/p>\n<p>angle_in_degrees = math.degrees(angle_in_radians)<\/p>\n<p>print(f&quot;atan(1) = {angle_in_degrees}\u00b0&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u516d\u3001\u53cc\u66f2\u4e09\u89d2\u51fd\u6570<\/h2>\n<\/p>\n<p><p>Python\u7684<code>math<\/code>\u6a21\u5757\u8fd8\u63d0\u4f9b\u4e86\u53cc\u66f2\u4e09\u89d2\u51fd\u6570\uff0c\u5982\u53cc\u66f2\u6b63\u5f26\u51fd\u6570\uff08<code>math.sinh()<\/code>\uff09\u3001\u53cc\u66f2\u4f59\u5f26\u51fd\u6570\uff08<code>math.cosh()<\/code>\uff09\u548c\u53cc\u66f2\u6b63\u5207\u51fd\u6570\uff08<code>math.tanh()<\/code>\uff09\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u8ba1\u7b97\u53cc\u66f2\u6b63\u5f26\u503c<\/h3>\n<\/p>\n<p><p>\u53cc\u66f2\u6b63\u5f26\u51fd\u6570\u8868\u793a\u4e3a<code>sinh(x)<\/code>\uff0c\u4f7f\u7528<code>math.sinh()<\/code>\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u53cc\u66f2\u6b63\u5f26\u503c<\/strong><\/h2>\n<p>value = 1<\/p>\n<p>sinh_value = math.sinh(value)<\/p>\n<p>print(f&quot;sinh(1) = {sinh_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u8ba1\u7b97\u53cc\u66f2\u4f59\u5f26\u503c<\/h3>\n<\/p>\n<p><p>\u53cc\u66f2\u4f59\u5f26\u51fd\u6570\u8868\u793a\u4e3a<code>cosh(x)<\/code>\uff0c\u4f7f\u7528<code>math.cosh()<\/code>\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u53cc\u66f2\u4f59\u5f26\u503c<\/strong><\/h2>\n<p>value = 1<\/p>\n<p>cosh_value = math.cosh(value)<\/p>\n<p>print(f&quot;cosh(1) = {cosh_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u8ba1\u7b97\u53cc\u66f2\u6b63\u5207\u503c<\/h3>\n<\/p>\n<p><p>\u53cc\u66f2\u6b63\u5207\u51fd\u6570\u8868\u793a\u4e3a<code>tanh(x)<\/code>\uff0c\u4f7f\u7528<code>math.tanh()<\/code>\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u53cc\u66f2\u6b63\u5207\u503c<\/strong><\/h2>\n<p>value = 1<\/p>\n<p>tanh_value = math.tanh(value)<\/p>\n<p>print(f&quot;tanh(1) = {tanh_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e03\u3001\u5e94\u7528\u573a\u666f<\/h2>\n<\/p>\n<p><h3>1\u3001\u51e0\u4f55\u8ba1\u7b97<\/h3>\n<\/p>\n<p><p>\u4e09\u89d2\u51fd\u6570\u5728\u51e0\u4f55\u8ba1\u7b97\u4e2d\u6709\u5e7f\u6cdb\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u8ba1\u7b97\u4e09\u89d2\u5f62\u7684\u9762\u79ef\u3001\u8ba1\u7b97\u591a\u8fb9\u5f62\u7684\u5916\u63a5\u5706\u534a\u5f84\u7b49\u90fd\u9700\u8981\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u4e09\u89d2\u5f62\u7684\u9762\u79ef<\/strong><\/h2>\n<p>a = 5  # \u8fb9\u957f<\/p>\n<p>b = 6  # \u8fb9\u957f<\/p>\n<p>angle_in_degrees = 30  # \u5939\u89d2<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<h2><strong>\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u8ba1\u7b97\u9762\u79ef<\/strong><\/h2>\n<p>area = 0.5 * a * b * math.sin(angle_in_radians)<\/p>\n<p>print(f&quot;\u4e09\u89d2\u5f62\u7684\u9762\u79ef = {area}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u7269\u7406\u5b66\u548c\u5de5\u7a0b\u5b66<\/h3>\n<\/p>\n<p><p>\u5728\u7269\u7406\u5b66\u548c\u5de5\u7a0b\u5b66\u4e2d\uff0c\u4e09\u89d2\u51fd\u6570\u7528\u4e8e\u63cf\u8ff0\u6ce2\u52a8\u3001\u632f\u52a8\u548c\u5176\u4ed6\u5468\u671f\u6027\u73b0\u8c61\u3002\u4f8b\u5982\uff0c\u5728\u5206\u6790\u7535\u8def\u4e2d\u7684\u4ea4\u6d41\u7535\u6d41\u65f6\uff0c\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u6765\u63cf\u8ff0\u7535\u6d41\u548c\u7535\u538b\u7684\u53d8\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u8ba1\u7b97\u4ea4\u6d41\u7535\u538b<\/strong><\/h2>\n<p>amplitude = 230  # \u7535\u538b\u632f\u5e45<\/p>\n<p>frequency = 50  # \u9891\u7387<\/p>\n<p>time = 0.01  # \u65f6\u95f4<\/p>\n<p>angle_in_radians = 2 * math.pi * frequency * time<\/p>\n<p>voltage = amplitude * math.sin(angle_in_radians)<\/p>\n<p>print(f&quot;\u4ea4\u6d41\u7535\u538b = {voltage}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66<\/h3>\n<\/p>\n<p><p>\u5728\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u4e2d\uff0c\u4e09\u89d2\u51fd\u6570\u7528\u4e8e\u65cb\u8f6c\u3001\u7f29\u653e\u548c\u53d8\u6362\u56fe\u5f62\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u4f59\u5f26\u548c\u6b63\u5f26\u51fd\u6570\u53ef\u4ee5\u5b9e\u73b0\u56fe\u5f62\u7684\u65cb\u8f6c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<h2><strong>\u65cb\u8f6c\u70b9 (x, y) 90 \u5ea6<\/strong><\/h2>\n<p>x = 1<\/p>\n<p>y = 0<\/p>\n<p>angle_in_degrees = 90<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<p>new_x = x * math.cos(angle_in_radians) - y * math.sin(angle_in_radians)<\/p>\n<p>new_y = x * math.sin(angle_in_radians) + y * math.cos(angle_in_radians)<\/p>\n<p>print(f&quot;\u65cb\u8f6c\u540e\u7684\u70b9: ({new_x}, {new_y})&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u516b\u3001\u4f18\u5316\u548c\u6027\u80fd<\/h2>\n<\/p>\n<p><h3>1\u3001\u51cf\u5c11\u91cd\u590d\u8ba1\u7b97<\/h3>\n<\/p>\n<p><p>\u5728\u9700\u8981\u591a\u6b21\u4f7f\u7528\u540c\u4e00\u89d2\u5ea6\u7684\u4e09\u89d2\u51fd\u6570\u503c\u65f6\uff0c\u53ef\u4ee5\u5c06\u5176\u63d0\u524d\u8ba1\u7b97\u5e76\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\uff0c\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u4ee5\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>angle_in_degrees = 45<\/p>\n<p>angle_in_radians = math.radians(angle_in_degrees)<\/p>\n<p>sin_value = math.sin(angle_in_radians)<\/p>\n<p>cos_value = math.cos(angle_in_radians)<\/p>\n<p>tan_value = math.tan(angle_in_radians)<\/p>\n<h2><strong>\u591a\u6b21\u4f7f\u7528 sin_value, cos_value, tan_value<\/strong><\/h2>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528NumPy\u5e93<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5927\u89c4\u6a21\u7684\u6570\u503c\u8ba1\u7b97\uff0c\u4f7f\u7528NumPy\u5e93\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6027\u80fd\u3002NumPy\u63d0\u4f9b\u4e86\u7c7b\u4f3c\u4e8e<code>math<\/code>\u6a21\u5757\u7684\u51fd\u6570\uff0c\u4f46\u5176\u5b9e\u73b0\u66f4\u9ad8\u6548\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u6570\u7ec4\u548c\u77e9\u9635\u65f6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>angles_in_degrees = np.array([0, 30, 45, 60, 90])<\/p>\n<p>angles_in_radians = np.radians(angles_in_degrees)<\/p>\n<h2><strong>\u4f7f\u7528 NumPy \u8ba1\u7b97\u4e09\u89d2\u51fd\u6570\u503c<\/strong><\/h2>\n<p>sin_values = np.sin(angles_in_radians)<\/p>\n<p>cos_values = np.cos(angles_in_radians)<\/p>\n<p>tan_values = np.tan(angles_in_radians)<\/p>\n<p>print(&quot;sin:&quot;, sin_values)<\/p>\n<p>print(&quot;cos:&quot;, cos_values)<\/p>\n<p>print(&quot;tan:&quot;, tan_values)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e5d\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7<code>math<\/code>\u6a21\u5757\uff0cPython\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\uff0c\u65b9\u4fbf\u6211\u4eec\u8fdb\u884c\u5404\u79cd\u6570\u503c\u8ba1\u7b97\u548c\u79d1\u5b66\u8ba1\u7b97\u3002<strong>\u719f\u7ec3\u638c\u63e1\u8fd9\u4e9b\u51fd\u6570\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u7684\u53ef\u8bfb\u6027<\/strong>\u3002\u5728\u6027\u80fd\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f\u4e0b\uff0c\u63a8\u8350\u4f7f\u7528NumPy\u5e93\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u8868\u73b0\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u8fdb\u884c\u8ba1\u7b97\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>math<\/code>\u6a21\u5757\u6765\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u3002\u8be5\u6a21\u5757\u63d0\u4f9b\u4e86\u591a\u79cd\u4e09\u89d2\u51fd\u6570\uff0c\u5982<code>sin()<\/code>\u3001<code>cos()<\/code>\u3001<code>tan()<\/code>\u7b49\u3002\u8fd9\u4e9b\u51fd\u6570\u63a5\u53d7\u5f27\u5ea6\u4f5c\u4e3a\u53c2\u6570\uff0c\u56e0\u6b64\u5728\u8fdb\u884c\u89d2\u5ea6\u8ba1\u7b97\u65f6\uff0c\u9700\u8981\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u5b9e\u73b0\u3002\u4f8b\u5982\uff0c\u8ba1\u7b9730\u5ea6\u7684\u6b63\u5f26\u503c\u53ef\u4ee5\u8fd9\u6837\u505a\uff1a  <\/p>\n<pre><code class=\"language-python\">import math\nangle = 30\nsine_value = math.sin(math.radians(angle))\nprint(sine_value)  # \u8f93\u51fa0.5\n<\/code><\/pre>\n<p><strong>Python\u4e2d\u5982\u4f55\u5904\u7406\u9006\u4e09\u89d2\u51fd\u6570\uff1f<\/strong><br \/>\u9006\u4e09\u89d2\u51fd\u6570\u540c\u6837\u53ef\u4ee5\u901a\u8fc7<code>math<\/code>\u6a21\u5757\u6765\u8c03\u7528\u3002\u5e38\u7528\u7684\u9006\u4e09\u89d2\u51fd\u6570\u6709<code>asin()<\/code>\u3001<code>acos()<\/code>\u548c<code>atan()<\/code>\u3002\u8fd9\u4e9b\u51fd\u6570\u8fd4\u56de\u7684\u662f\u5f27\u5ea6\u503c\uff0c\u8981\u5c06\u5176\u8f6c\u6362\u4e3a\u89d2\u5ea6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>math.degrees()<\/code>\u51fd\u6570\u3002\u4f8b\u5982\uff0c\u8ba1\u7b97\u6b63\u5f26\u503c\u4e3a0.5\u7684\u89d2\u5ea6\uff1a  <\/p>\n<pre><code class=\"language-python\">import math\nsine_value = 0.5\nangle = math.degrees(math.asin(sine_value))\nprint(angle)  # \u8f93\u51fa30.0\n<\/code><\/pre>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u4e09\u89d2\u51fd\u6570\u7684\u5468\u671f\u6027\u95ee\u9898\uff1f<\/strong><br \/>\u4e09\u89d2\u51fd\u6570\u5177\u6709\u5468\u671f\u6027\u7279\u5f81\uff0c\u56e0\u6b64\u5728\u8ba1\u7b97\u65f6\u9700\u8981\u6ce8\u610f\u89d2\u5ea6\u7684\u8303\u56f4\u3002\u53ef\u4ee5\u4f7f\u7528\u6a21\u8fd0\u7b97\u6765\u9650\u5236\u89d2\u5ea6\u57280\u5230360\u5ea6\u62160\u52302\u03c0\u5f27\u5ea6\u4e4b\u95f4\u3002\u4f8b\u5982\uff0c\u4e3a\u4e86\u786e\u4fdd\u8ba1\u7b97\u7684\u89d2\u5ea6\u57280\u5230360\u5ea6\u4e4b\u95f4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">import math\nangle = 750  # \u8d85\u8fc7360\u5ea6\nangle = angle % 360  # \u8f6c\u6362\u52300-360\u5ea6\nsine_value = math.sin(math.radians(angle))\nprint(sine_value)  # \u8f93\u51fa\u76f8\u5e94\u7684\u6b63\u5f26\u503c\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u6709\u6548\u907f\u514d\u7531\u4e8e\u89d2\u5ea6\u8d85\u8fc7\u5468\u671f\u800c\u5bfc\u81f4\u7684\u9519\u8bef\u8ba1\u7b97\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u5927\u5168 \u5728Python\u7f16\u7a0b\u4e2d\uff0c\u8c03\u7528\u4e09\u89d2\u51fd\u6570\u516c\u5f0f\u975e\u5e38\u7b80\u5355\u3002Python\u7684\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00 [&hellip;]","protected":false},"author":3,"featured_media":1124535,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1124527"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1124527"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1124527\/revisions"}],"predecessor-version":[{"id":1124538,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1124527\/revisions\/1124538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1124535"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1124527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1124527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1124527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}