{"id":1112014,"date":"2025-01-08T17:34:38","date_gmt":"2025-01-08T09:34:38","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1112014.html"},"modified":"2025-01-08T17:34:40","modified_gmt":"2025-01-08T09:34:40","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e8%be%93%e5%85%a5%e4%b8%89%e8%a7%92%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1112014.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u8f93\u5165\u4e09\u89d2\u51fd\u6570"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074218\/a5edb8fd-4996-4c36-83b9-53c214551dc6.webp\" alt=\"python\u4e2d\u5982\u4f55\u8f93\u5165\u4e09\u89d2\u51fd\u6570\" \/><\/p>\n<p><p> <strong>Python\u4e2d\u5982\u4f55\u8f93\u5165\u4e09\u89d2\u51fd\u6570<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u8f93\u5165\u4e09\u89d2\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Python\u7684\u6570\u5b66\u5e93\u2014\u2014<code>math<\/code>\u6a21\u5757\u6765\u5b9e\u73b0\u3002<strong>\u9996\u5148\u5bfc\u5165math\u6a21\u5757\u3001\u4f7f\u7528\u51fd\u6570\u5982<code>sin()<\/code>\u3001<code>cos()<\/code>\u3001<code>tan()<\/code>\uff0c\u5e76\u4e14\u8981\u6ce8\u610f\u89d2\u5ea6\u4e0e\u5f27\u5ea6\u7684\u8f6c\u6362<\/strong>\u3002 \u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u6765\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u7136\u540e\u518d\u8ba1\u7b97\u4e09\u89d2\u51fd\u6570\u7684\u503c\u3002\u8fd9\u91cc\u6211\u4eec\u8be6\u7ec6\u5c55\u5f00\u4f7f\u7528 <code>math<\/code> \u6a21\u5757\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5bfc\u5165math\u6a21\u5757<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<code>math<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u8bb8\u591a\u6570\u5b66\u51fd\u6570\uff0c\u5176\u4e2d\u5305\u62ec\u5404\u79cd\u4e09\u89d2\u51fd\u6570\u3002\u5728\u5f00\u59cb\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u5bfc\u5165<code>math<\/code>\u6a21\u5757\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u7b80\u5355\u7684\u4ee3\u7801\u884c\u6765\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><p>\u5bfc\u5165<code>math<\/code>\u6a21\u5757\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528\u5176\u4e2d\u7684\u4e09\u89d2\u51fd\u6570\u4e86\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u57fa\u672c\u4e09\u89d2\u51fd\u6570<\/p>\n<\/p>\n<ol>\n<li><strong>\u6b63\u5f26\u51fd\u6570\uff08sin\uff09<\/strong><\/li>\n<\/ol>\n<p><p><code>math.sin()<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e00\u4e2a\u89d2\u5ea6\u7684\u6b63\u5f26\u503c\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<code>math.sin()<\/code>\u51fd\u6570\u63a5\u53d7\u7684\u53c2\u6570\u662f\u5f27\u5ea6\u800c\u4e0d\u662f\u89d2\u5ea6\u3002\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u89d2\u5ea6\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u5c06\u5176\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>angle_degrees = 30  # \u89d2\u5ea6<\/p>\n<p>angle_radians = math.radians(angle_degrees)  # \u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<p>sin_value = math.sin(angle_radians)  # \u8ba1\u7b97\u6b63\u5f26\u503c<\/p>\n<p>print(f&quot;Sin({angle_degrees} degrees) = {sin_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f59\u5f26\u51fd\u6570\uff08cos\uff09<\/strong><\/li>\n<\/ol>\n<p><p><code>math.cos()<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e00\u4e2a\u89d2\u5ea6\u7684\u4f59\u5f26\u503c\u3002\u4e0e<code>math.sin()<\/code>\u7c7b\u4f3c\uff0c\u5b83\u4e5f\u63a5\u53d7\u5f27\u5ea6\u4f5c\u4e3a\u53c2\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>angle_degrees = 60  # \u89d2\u5ea6<\/p>\n<p>angle_radians = math.radians(angle_degrees)  # \u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<p>cos_value = math.cos(angle_radians)  # \u8ba1\u7b97\u4f59\u5f26\u503c<\/p>\n<p>print(f&quot;Cos({angle_degrees} degrees) = {cos_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u6b63\u5207\u51fd\u6570\uff08tan\uff09<\/strong><\/li>\n<\/ol>\n<p><p><code>math.tan()<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e00\u4e2a\u89d2\u5ea6\u7684\u6b63\u5207\u503c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>angle_degrees = 45  # \u89d2\u5ea6<\/p>\n<p>angle_radians = math.radians(angle_degrees)  # \u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<p>tan_value = math.tan(angle_radians)  # \u8ba1\u7b97\u6b63\u5207\u503c<\/p>\n<p>print(f&quot;Tan({angle_degrees} degrees) = {tan_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528\u53cd\u4e09\u89d2\u51fd\u6570<\/p>\n<\/p>\n<p><p><code>math<\/code>\u6a21\u5757\u8fd8\u63d0\u4f9b\u4e86\u53cd\u4e09\u89d2\u51fd\u6570\uff0c\u7528\u4e8e\u4ece\u4e09\u89d2\u51fd\u6570\u7684\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<ol>\n<li><strong>\u53cd\u6b63\u5f26\u51fd\u6570\uff08asin\uff09<\/strong><\/li>\n<\/ol>\n<p><p><code>math.asin()<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u6b63\u5f26\u503c\u7684\u53cd\u6b63\u5f26\u503c\uff0c\u5e76\u8fd4\u56de\u7ed3\u679c\u7684\u5f27\u5ea6\u503c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>sin_value = 0.5<\/p>\n<p>angle_radians = math.asin(sin_value)  # \u8ba1\u7b97\u53cd\u6b63\u5f26\u503c<\/p>\n<p>angle_degrees = math.degrees(angle_radians)  # \u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/p>\n<p>print(f&quot;Asin({sin_value}) = {angle_degrees} degrees&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u53cd\u4f59\u5f26\u51fd\u6570\uff08acos\uff09<\/strong><\/li>\n<\/ol>\n<p><p><code>math.acos()<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u4f59\u5f26\u503c\u7684\u53cd\u4f59\u5f26\u503c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>cos_value = 0.5<\/p>\n<p>angle_radians = math.acos(cos_value)  # \u8ba1\u7b97\u53cd\u4f59\u5f26\u503c<\/p>\n<p>angle_degrees = math.degrees(angle_radians)  # \u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/p>\n<p>print(f&quot;Acos({cos_value}) = {angle_degrees} degrees&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u53cd\u6b63\u5207\u51fd\u6570\uff08atan\uff09<\/strong><\/li>\n<\/ol>\n<p><p><code>math.atan()<\/code>\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u6b63\u5207\u503c\u7684\u53cd\u6b63\u5207\u503c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>tan_value = 1<\/p>\n<p>angle_radians = math.atan(tan_value)  # \u8ba1\u7b97\u53cd\u6b63\u5207\u503c<\/p>\n<p>angle_degrees = math.degrees(angle_radians)  # \u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/p>\n<p>print(f&quot;Atan({tan_value}) = {angle_degrees} degrees&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u5904\u7406\u89d2\u5ea6\u548c\u5f27\u5ea6\u7684\u8f6c\u6362<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u65f6\uff0c\u901a\u5e38\u9700\u8981\u5728\u89d2\u5ea6\u548c\u5f27\u5ea6\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u3002<code>math<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u4e24\u4e2a\u975e\u5e38\u6709\u7528\u7684\u51fd\u6570\uff1a<code>math.radians()<\/code>\u548c<code>math.degrees()<\/code>\uff0c\u7528\u4e8e\u89d2\u5ea6\u548c\u5f27\u5ea6\u4e4b\u95f4\u7684\u8f6c\u6362\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u53ef\u4ee5\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>angle_degrees = 90<\/p>\n<p>angle_radians = math.radians(angle_degrees)  # \u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6<\/p>\n<p>print(f&quot;{angle_degrees} degrees = {angle_radians} radians&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528<code>math.degrees()<\/code>\u51fd\u6570\u53ef\u4ee5\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>angle_radians = math.pi \/ 2<\/p>\n<p>angle_degrees = math.degrees(angle_radians)  # \u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/p>\n<p>print(f&quot;{angle_radians} radians = {angle_degrees} degrees&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528hypot\u51fd\u6570\u8ba1\u7b97\u659c\u8fb9<\/p>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u51e0\u4f55\u8ba1\u7b97\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u8ba1\u7b97\u4e00\u4e2a\u76f4\u89d2\u4e09\u89d2\u5f62\u7684\u659c\u8fb9\u957f\u5ea6\u3002<code>math<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86<code>math.hypot()<\/code>\u51fd\u6570\u6765\u7b80\u5316\u8fd9\u4e00\u8ba1\u7b97\u3002<code>math.hypot(x, y)<\/code>\u51fd\u6570\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u5206\u522b\u8868\u793a\u76f4\u89d2\u4e09\u89d2\u5f62\u7684\u4e24\u4e2a\u76f4\u89d2\u8fb9\u7684\u957f\u5ea6\uff0c\u5e76\u8fd4\u56de\u659c\u8fb9\u7684\u957f\u5ea6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>x = 3<\/p>\n<p>y = 4<\/p>\n<p>hypotenuse = math.hypot(x, y)  # \u8ba1\u7b97\u659c\u8fb9\u957f\u5ea6<\/p>\n<p>print(f&quot;The hypotenuse of a right triangle with sides {x} and {y} is {hypotenuse}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u4f7f\u7528\u5176\u4ed6\u4e09\u89d2\u51fd\u6570<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u4e09\u89d2\u51fd\u6570\u5916\uff0c<code>math<\/code>\u6a21\u5757\u8fd8\u63d0\u4f9b\u4e86\u5176\u4ed6\u4e00\u4e9b\u6709\u7528\u7684\u4e09\u89d2\u51fd\u6570\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>math.sinh()\u3001math.cosh()\u3001math.tanh()<\/strong><\/li>\n<\/ol>\n<p><p>\u8fd9\u4e9b\u51fd\u6570\u5206\u522b\u7528\u4e8e\u8ba1\u7b97\u53cc\u66f2\u6b63\u5f26\u3001\u53cc\u66f2\u4f59\u5f26\u548c\u53cc\u66f2\u6b63\u5207\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>x = 1<\/p>\n<p>sinh_value = math.sinh(x)  # \u8ba1\u7b97\u53cc\u66f2\u6b63\u5f26<\/p>\n<p>cosh_value = math.cosh(x)  # \u8ba1\u7b97\u53cc\u66f2\u4f59\u5f26<\/p>\n<p>tanh_value = math.tanh(x)  # \u8ba1\u7b97\u53cc\u66f2\u6b63\u5207<\/p>\n<p>print(f&quot;Sinh({x}) = {sinh_value}&quot;)<\/p>\n<p>print(f&quot;Cosh({x}) = {cosh_value}&quot;)<\/p>\n<p>print(f&quot;Tanh({x}) = {tanh_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>math.asinh()\u3001math.acosh()\u3001math.atanh()<\/strong><\/li>\n<\/ol>\n<p><p>\u8fd9\u4e9b\u51fd\u6570\u5206\u522b\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u503c\u7684\u53cd\u53cc\u66f2\u6b63\u5f26\u3001\u53cd\u53cc\u66f2\u4f59\u5f26\u548c\u53cd\u53cc\u66f2\u6b63\u5207\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import math<\/p>\n<p>x = 1<\/p>\n<p>asinh_value = math.asinh(x)  # \u8ba1\u7b97\u53cd\u53cc\u66f2\u6b63\u5f26<\/p>\n<p>acosh_value = math.acosh(x + 1)  # \u8ba1\u7b97\u53cd\u53cc\u66f2\u4f59\u5f26\uff08\u6ce8\u610f\u8f93\u5165\u503c\u9700\u8981\u5927\u4e8e\u7b49\u4e8e1\uff09<\/p>\n<p>atanh_value = math.atanh(0.5)  # \u8ba1\u7b97\u53cd\u53cc\u66f2\u6b63\u5207<\/p>\n<p>print(f&quot;Asinh({x}) = {asinh_value}&quot;)<\/p>\n<p>print(f&quot;Acosh({x + 1}) = {acosh_value}&quot;)<\/p>\n<p>print(f&quot;Atanh(0.5) = {atanh_value}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e03\u3001\u4f7f\u7528numpy\u5e93\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97<\/p>\n<\/p>\n<p><p>\u9664\u4e86<code>math<\/code>\u6a21\u5757\u5916\uff0c<code>numpy<\/code>\u5e93\u4e5f\u662f\u8fdb\u884c\u6570\u5b66\u8ba1\u7b97\u7684\u5f3a\u5927\u5de5\u5177\u3002<code>numpy<\/code>\u5e93\u63d0\u4f9b\u4e86\u66f4\u4e30\u5bcc\u7684\u51fd\u6570\u548c\u66f4\u9ad8\u6548\u7684\u6570\u7ec4\u64cd\u4f5c\uff0c\u975e\u5e38\u9002\u5408\u5904\u7406\u5927\u89c4\u6a21\u7684\u79d1\u5b66\u8ba1\u7b97\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528numpy\u8ba1\u7b97\u6b63\u5f26\u51fd\u6570<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>angles_degrees = np.array([0, 30, 45, 60, 90])  # \u89d2\u5ea6\u6570\u7ec4<\/p>\n<p>angles_radians = np.radians(angles_degrees)  # \u5c06\u89d2\u5ea6\u6570\u7ec4\u8f6c\u6362\u4e3a\u5f27\u5ea6\u6570\u7ec4<\/p>\n<p>sin_values = np.sin(angles_radians)  # \u8ba1\u7b97\u6b63\u5f26\u503c<\/p>\n<p>print(f&quot;Angles (degrees): {angles_degrees}&quot;)<\/p>\n<p>print(f&quot;Sin values: {sin_values}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u4f7f\u7528numpy\u8ba1\u7b97\u4f59\u5f26\u51fd\u6570<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>angles_degrees = np.array([0, 30, 45, 60, 90])  # \u89d2\u5ea6\u6570\u7ec4<\/p>\n<p>angles_radians = np.radians(angles_degrees)  # \u5c06\u89d2\u5ea6\u6570\u7ec4\u8f6c\u6362\u4e3a\u5f27\u5ea6\u6570\u7ec4<\/p>\n<p>cos_values = np.cos(angles_radians)  # \u8ba1\u7b97\u4f59\u5f26\u503c<\/p>\n<p>print(f&quot;Angles (degrees): {angles_degrees}&quot;)<\/p>\n<p>print(f&quot;Cos values: {cos_values}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u4f7f\u7528numpy\u8ba1\u7b97\u6b63\u5207\u51fd\u6570<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>angles_degrees = np.array([0, 30, 45, 60, 90])  # \u89d2\u5ea6\u6570\u7ec4<\/p>\n<p>angles_radians = np.radians(angles_degrees)  # \u5c06\u89d2\u5ea6\u6570\u7ec4\u8f6c\u6362\u4e3a\u5f27\u5ea6\u6570\u7ec4<\/p>\n<p>tan_values = np.tan(angles_radians)  # \u8ba1\u7b97\u6b63\u5207\u503c<\/p>\n<p>print(f&quot;Angles (degrees): {angles_degrees}&quot;)<\/p>\n<p>print(f&quot;Tan values: {tan_values}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u4f7f\u7528numpy\u8ba1\u7b97\u53cd\u4e09\u89d2\u51fd\u6570<\/strong><\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>sin_values = np.array([0, 0.5, 0.707, 0.866, 1])  # \u6b63\u5f26\u503c\u6570\u7ec4<\/p>\n<p>angles_radians = np.arcsin(sin_values)  # \u8ba1\u7b97\u53cd\u6b63\u5f26\u503c\uff08\u5f27\u5ea6\uff09<\/p>\n<p>angles_degrees = np.degrees(angles_radians)  # \u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6<\/p>\n<p>print(f&quot;Sin values: {sin_values}&quot;)<\/p>\n<p>print(f&quot;Angles (degrees): {angles_degrees}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516b\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u8f93\u5165\u548c\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u662f\u975e\u5e38\u7b80\u5355\u548c\u76f4\u89c2\u7684\u3002\u901a\u8fc7\u5bfc\u5165<code>math<\/code>\u6a21\u5757\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u8ba1\u7b97\u6b63\u5f26\u3001\u4f59\u5f26\u3001\u6b63\u5207\u53ca\u5176\u53cd\u51fd\u6570\u503c\u3002\u6b64\u5916\uff0c\u4e86\u89e3\u5982\u4f55\u5728\u89d2\u5ea6\u548c\u5f27\u5ea6\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u4e3a\u5927\u591a\u6570\u4e09\u89d2\u51fd\u6570\u90fd\u63a5\u53d7\u5f27\u5ea6\u4f5c\u4e3a\u53c2\u6570\u3002<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u5904\u7406\u5927\u89c4\u6a21\u7684\u79d1\u5b66\u8ba1\u7b97\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>numpy<\/code>\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u9ad8\u6548\u7684\u6570\u7ec4\u64cd\u4f5c\u548c\u66f4\u4e30\u5bcc\u7684\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><p>\u603b\u4e4b\uff0c\u638c\u63e1\u8fd9\u4e9b\u57fa\u672c\u7684\u4e09\u89d2\u51fd\u6570\u548c\u8f6c\u6362\u65b9\u6cd5\u5c06\u4f7f\u4f60\u80fd\u591f\u8f7b\u677e\u5e94\u5bf9\u5404\u79cd\u6570\u5b66\u548c\u51e0\u4f55\u8ba1\u7b97\u4efb\u52a1\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u89d2\u5ea6\u8ba1\u7b97\u8fd8\u662f\u590d\u6742\u7684\u79d1\u5b66\u8ba1\u7b97\uff0cPython\u90fd\u80fd\u4e3a\u4f60\u63d0\u4f9b\u5f3a\u5927\u7684\u5de5\u5177\u548c\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python\u4e2d\u5982\u4f55\u4f7f\u7528\u4e09\u89d2\u51fd\u6570\u5e93\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u5b66\u5e93\uff0c\u540d\u4e3a<code>math<\/code>\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u5e38\u7528\u7684\u4e09\u89d2\u51fd\u6570\u3002\u8981\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\uff0c\u9996\u5148\u9700\u8981\u5bfc\u5165<code>math<\/code>\u6a21\u5757\u3002\u4f7f\u7528<code>math.sin()<\/code>\u3001<code>math.cos()<\/code>\u548c<code>math.tan()<\/code>\u7b49\u51fd\u6570\u53ef\u4ee5\u8ba1\u7b97\u89d2\u5ea6\u7684\u6b63\u5f26\u3001\u4f59\u5f26\u548c\u6b63\u5207\u503c\u3002\u8bf7\u6ce8\u610f\uff0c\u8fd9\u4e9b\u51fd\u6570\u63a5\u53d7\u5f27\u5ea6\u4f5c\u4e3a\u8f93\u5165\uff0c\u56e0\u6b64\u5728\u8ba1\u7b97\u524d\u53ef\u80fd\u9700\u8981\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u65b9\u6cd5\u662f\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5904\u7406\u89d2\u5ea6\u4e0e\u5f27\u5ea6\u4e4b\u95f4\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u5728\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\u65f6\uff0c\u5e38\u5e38\u9700\u8981\u5728\u89d2\u5ea6\u4e0e\u5f27\u5ea6\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u3002\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>math.radians()<\/code>\u51fd\u6570\u5c06\u89d2\u5ea6\u8f6c\u6362\u4e3a\u5f27\u5ea6\uff0c\u4f7f\u7528<code>math.degrees()<\/code>\u51fd\u6570\u5c06\u5f27\u5ea6\u8f6c\u6362\u4e3a\u89d2\u5ea6\u3002\u4f8b\u5982\uff0c<code>math.sin(math.radians(30))<\/code>\u53ef\u4ee5\u8ba1\u7b9730\u5ea6\u7684\u6b63\u5f26\u503c\uff0c\u7ed3\u679c\u4e3a0.5\u3002<\/p>\n<p><strong>Python\u4e2d\u662f\u5426\u6709\u5176\u4ed6\u5e93\u53ef\u4ee5\u7528\u4e8e\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\uff1f<\/strong><br \/>\u9664\u4e86\u5185\u7f6e\u7684<code>math<\/code>\u5e93\uff0cPython\u8fd8\u63d0\u4f9b\u4e86\u5176\u4ed6\u4e00\u4e9b\u5e93\uff0c\u5982<code>numpy<\/code>\uff0c\u4e13\u95e8\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u7ec4\u64cd\u4f5c\u3002<code>numpy<\/code>\u5e93\u4e5f\u5305\u542b\u4e86\u4e09\u89d2\u51fd\u6570\uff0c\u4f7f\u7528\u65b9\u6cd5\u7c7b\u4f3c\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>numpy.sin()<\/code>\u548c<code>numpy.cos()<\/code>\u53ef\u4ee5\u5bf9\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u540c\u65f6\u8fdb\u884c\u4e09\u89d2\u51fd\u6570\u8ba1\u7b97\uff0c\u8fd9\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u975e\u5e38\u9ad8\u6548\u3002\u4f7f\u7528<code>numpy<\/code>\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u5bfc\u5165\u8be5\u5e93\uff1a<code>import numpy as np<\/code>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u5982\u4f55\u8f93\u5165\u4e09\u89d2\u51fd\u6570 \u5728Python\u4e2d\u8f93\u5165\u4e09\u89d2\u51fd\u6570\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Python\u7684\u6570\u5b66\u5e93\u2014\u2014math\u6a21\u5757\u6765 [&hellip;]","protected":false},"author":3,"featured_media":1112017,"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\/1112014"}],"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=1112014"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1112014\/revisions"}],"predecessor-version":[{"id":1112019,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1112014\/revisions\/1112019"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1112017"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1112014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1112014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1112014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}