'module' object has no attribute 'testmod' Python求助def f2c(t): """ >>>f2c(212) 100 >>>f2c(32) 0 >>>f2c(-40) -40 >>>f2c(36) 2 >>>f2c(37) 3 >>>f2c(38) 3 >>>f2c(39) 4 """

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/14 19:07:40
'module' object has no attribute 'testmod' Python求助def f2c(t):    >>f2c(212) 100 >>>f2c(32) 0 >>>f2c(-40) -40 >>>f2c(36) 2 >>>f2c(37) 3 >>>f2c(38) 3 >>>f2c(39) 4 """" />

'module' object has no attribute 'testmod' Python求助def f2c(t): """ >>>f2c(212) 100 >>>f2c(32) 0 >>>f2c(-40) -40 >>>f2c(36) 2 >>>f2c(37) 3 >>>f2c(38) 3 >>>f2c(39) 4 """
'module' object has no attribute 'testmod' Python求助
def f2c(t):
"""
>>>f2c(212)
100
>>>f2c(32)
0
>>>f2c(-40)
-40
>>>f2c(36)
2
>>>f2c(37)
3
>>>f2c(38)
3
>>>f2c(39)
4
"""
s = float((int(t)-32)*5)/9
print int(round(s))
if __name__ == '__main__':
import doctest
doctest.testmod()
它返回了
Traceback (most recent call last):
File "F:\text\计算机导论\python\1204.8.py", line 23, in
doctest.testmod()
AttributeError: 'module' object has no attribute 'testmod'

'module' object has no attribute 'testmod' Python求助def f2c(t): """ >>>f2c(212) 100 >>>f2c(32) 0 >>>f2c(-40) -40 >>>f2c(36) 2 >>>f2c(37) 3 >>>f2c(38) 3 >>>f2c(39) 4 """
你的doctest是不是被改过了?

>>>后面少一个空格,应该
>>> f2c(-40)