Discuss / Python / 报错

报错

Topic source

胡朵kura

#1 Created at ... [Delete] [Delete and Lock User]

>>> from move import move

>>> x,y = move(100,100,60,math.pi / 6)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "E:\ToolPY\move.py", line 6, in move

    ny = y - step * math.sin(angle)

NameError: name 'ny' is not defined

>>>

求助

冰茶71_350

#2 Created at ... [Delete] [Delete and Lock User]

模块

import math

def move(x, y, step, angle=0):

    nx = x + step * math.cos(angle)

    ny = y - step * math.sin(angle)

    return nx, ny

调用

import math

from move import move                                                                                                    

x1, y1 = move.move(100, 100, 60, math.pi / 6)                                                                   

x1, y1

冰茶71_350

#3 Created at ... [Delete] [Delete and Lock User]

看下你模块里的代码缩进,要不就发出来让大家看下


  • 1

Reply