import 调用模块并重命名函数,报错问题。

import语句调用a_1模块中的函数car_massage(),并将函数重新临时命名为c_m

def car_massage(name, long, **other):
cars_massage = {}
cars_massage['name'] = name
cars_massage['long'] = long
for key, value in other.items():
cars_massage[key] = value
return cars_massage

上面是模块a_1

from a_1 import car_massage as c_m

car = a_1.c_m('l', 'q', d='s', s='x')
print(car)

上面是新建.py文件,调用a_1模块,并给函数重命名。
最后打印报错:AttributeError: module 'a_1' has no attribute 'c_m'

你已经引入并重命名了,下面使用直接用c_m即可,不需要加a_1