简体   繁体   English

在 Python 中导入特定字符的 package

[英]Import package with specific character in Python

I'm trying to import package in Python, but the is name include a '-' from package-name import * says my - is invalid syntax Can I fix it wihtout rename anything?我正在尝试在 Python 中导入 package,但是 is name 包含一个 '-' from package-name import * 说我的 - 语法无效 我可以修复它而不重命名任何东西吗? Screenshot of the invalid syntax error无效语法错误的屏幕截图

as is written here: Python module with a dash, or hyphen (-) in its name如此处所写: Python 名称中带有破折号或连字符 (-) 的模块

You can do that using import ().您可以使用import () 来做到这一点。 For example:例如:

foobar = __import__("foo-bar")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM