|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
一个写有函数的文本,保存在了默认的Lib>idlelib 文件夹里, idle里可以import, 但是却不能调用。只能把文本里的函数再写一遍才能调用。那么该文本应该保存在哪个文件路径里,才可以被import之后直接调用而不必再把文本内容写一遍呢?谢谢!!
>>>import Tgrating
>>> Tgrating(45,1.55,0.966,-1)
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
Tgrating(45,1.55,0.966,-1)
TypeError: 'module' object is not callable
>>> import math
>>> def Tgrating(inc,lamda,l,m):
ref=math.sin(math.radians(inc))+m*lamda*l
try:
ref=-math.degrees(math.asin(ref))
return ref
except ValueError as reason:
if m==0:
o='zero-th'
else :
o='%dst'%m
print('Diffraction light at',o,' order doesn\'t exist')
>>> Tgrating(45,1.55,0.966,-1)
52.20357175788754 |
|