[英]How do I successfully import something from a module which has the same name as a reserved function or keyword in Python?
in Python, I am trying to import the open
function object from the built-in os
module, but it would not let me import it as it has the same name as the built-in open
function, which is used for opening files. 如何从与保留的内置函数/关键字同名的模块中导入对象/属性?
喜欢
from os import open
您可以使用as
别名。
from os import open as osopen
您可以通过as
作为另一个名称导入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.