'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/07/08 18:59:15
!['module' object has no attribute 'testmod' Python求助def f2c(t):](/uploads/image/z/14452143-15-3.jpg?t=%27module%27+object+has+no+attribute+%27testmod%27+Python%E6%B1%82%E5%8A%A9def+f2c%28t%29%3A++++%22%22%22++++++%3E%3E%3Ef2c%28212%29++++++100++++++%3E%3E%3Ef2c%2832%29++++++0++++++%3E%3E%3Ef2c%28-40%29++++++-40++++++%3E%3E%3Ef2c%2836%29++++++2++++++%3E%3E%3Ef2c%2837%29++++++3++++++%3E%3E%3Ef2c%2838%29++++++3++++++%3E%3E%3Ef2c%2839%29++++++4++++%22%22%22)
'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)