python 报错 TypeError: ‘module‘ object is not callable

如下代码即报错

import datetime as date

the_date = date(2020,5,2)
print(the_date)
TypeError: 'module' object is not callable

顾名思义,就是把模块当作函数用了

import 这一行改为:

from datetime import date

即可

猜你喜欢

转载自blog.csdn.net/weixin_41888257/article/details/112297494