小编How*_*ame的帖子

如何使用不支持异步的库?

我正在从烧瓶转移到 aiohttp,我需要在不支持异步的 Oracle 数据库中执行一些查询。所以我想知道如何在 aiohttp 中做到这一点?

这个怎么样?

http://pastebin.com/nbWABbvK

或者还有其他(正确的)方法来做到这一点?

提前致谢!

cx-oracle python-3.x async-await python-asyncio aiohttp

3
推荐指数
1
解决办法
1328
查看次数

GO接口的多态性

我试图在GO中实现这种多态性

type Discoverer interface {
    Discover() string
}

type A struct {
}

func (obj A) GetTest() string {
    return "im in A"
}

type B struct {
    A
}

func (obj B) GetTest() string {
    return "im in B"
}

func (obj A) Discover() string {
    return obj.GetTest()
}

func main() {
    a := A{}
    b := B{}

    fmt.Println(a.Discover())
    fmt.Println(b.Discover())
}
Run Code Online (Sandbox Code Playgroud)

现在我进入输出

im in A
im in A
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是:可以在输出中看到

im in A
im in B
Run Code Online (Sandbox Code Playgroud)

没有"覆盖"发现B?

func (obj B) …
Run Code Online (Sandbox Code Playgroud)

polymorphism class go

1
推荐指数
1
解决办法
188
查看次数