擅长:python、mysql、java
<p>如果不需要额外的依赖项,可以使用<code>try</code><code>except</code>块在同一别名下导入任意一个模块…:</p>
<pre><code>try:
import urllib.request as urlrequest
except ImportError:
import urllib as urlrequest
url = "https://github.com/OpenExoplanetCatalogue/oec_gzip/raw/master/systems.xml.gz"
oec = ET.parse(gzip.GzipFile(fileobj=io.BytesIO(urlrequest.urlopen(url).read())))
</code></pre>