问题描述
不确定如何在类中嵌入外部库以使其独立,我选择了:
- hosts: all
tasks:
我用其他库做了同样的事情并且工作正常,但没有打开 url,它给了我错误:
from urllib.request import urlopen
class MyClass:
from urllib.request import urlopen as LOCALurlopen
LOC_baseUrl = 'https://www.someurl.com/api/'
def resolve_API(self,myValue):
LOC_fullRequest = self.LOC_baseUrl + '/' + myValue
print(Loc_fullRequest)
LOC_response = urlopen(LOC_fullRequest,timeout = 5).read() ## works,but external dependecy
LOC_response = self.LOCALurlopen(LOC_fullRequest,timeout = 5).read() ## doesn't work
print(LOC_response)
我应该如何解决这个依赖?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)