python导包问题
如图,为什么from .name_function import get_formatted_name以后,运行names.py报错呢,出错提示:
回答:
names.py 如果作为顶层脚本运行的话,不能relative import,只能absolute import。如果你不确定names.py 到底怎么用,可以这么写
try: from .xxx import yyy
except:
from xxx import yyy
以上是 python导包问题 的全部内容, 来源链接: utcz.com/p/937704.html