ImportError: cannot import name 'my_function' from 'abc'

ImportError: cannot import name 'my_function' from 'abc'

正在尝试将 python 脚本从计算机加载到 google colab,但显示 importError

abc 模块在代码中没有 my_function class/attribute/function/etc 这是读取 abc 模块的示例转到 python_home/Lib/abc.py 并读取写入的 _abc 模块在 C 中转到 https://github.com/python/cpython/blob/master/Modules/_abc.c 在 github

将文件名 abc.py 更改为其他名称,例如 testo.py,它将起作用。

from google.colab import files

upload = files.upload()

检查 !ls

testo.py

尝试:

import testo

testo.myfunction()

你好世界!

说明:abc 是一个内置模块,您不应该为您的模块使用该名称。查看此问题了解更多 info.