擅长:python、mysql、java
<p>禁止使用<code>'triangle'</code>只使用<code>triangle</code></p>
<p>因此,您的代码如下所示:</p>
<pre><code>from turtle import*
from math import*
def triangle():
triangle=(int(bodylength))/5*3/2/cos(70)
penup()
forward(int(bodylength)/5)
pendown()
left(70)
forward(int(triangle))
right(140)
forward(int(triangle))
forward(int(bodylength)/5)
triangle()
</code></pre>
<p>需要这样做是因为<code>'triangle'</code>到python是一个<em>字符串</em>而不是<em>变量</em>。要了解更多关于变量和字符串的信息,只需通过google搜索字符串和变量之间的区别</p>
<p>注意:您的代码可能还有其他错误,如<code>forward()</code>。你可能需要打电话给<code>turtle.forward()</code>什么的。我还认为<code>Math.cos()</code>采用rad而不是deg作为参数。你知道吗</p>