我是编程初学者,我需要为大学课程做好准备。我使用的程序是Spyder(昨晚下载),我必须在'python'中编码。我已经下载了所需的版本,但我似乎无法运行简单的代码。Python(spyder) - 名称'debugfile'未定义
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import math
def circleAreaFromDiameter(d):
"""takes a float d and returns the area of a cirlce with diameter d.
"""
Area = math.pi * d**2/4.0
return Area
print circleAreaFromDiameter(1)
最后一行,“打印circleAreaFromDiameter(1)”在它的侧面有一个感叹号说这是一个无效的语法。我不明白为什么,但我不认为这是我的问题。
当我按下“运行文件”或“调试文件”,它说:
回溯(最近通话最后一个): 文件“”,1号线,在 NameError:名字“运行文件”被没有定义
或
回溯(最近最后一次通话): 文件 “”,1号线,在 NameError:名字 'debugfile' 没有定义
我会REA非常感谢任何帮助。
它看起来像你使用的是IDE。不要忘了解释你如何运行你的程序,因为这会帮助人们回答你的问题。另外,如果你想有一个空的函数,你可以使用'pass'语句。 – pedromanoel