Discuss / Python / 看了很久,试着解释几个问题,供参考。

看了很久,试着解释几个问题,供参考。

Topic source

1.看不懂的童鞋试着把所有的yeild from去掉就好理解了。 aiomysql provides same api you just need to use yield from conn.f() instead of just call conn.f() for every method. 这个Pool和SQL语句的定义基本是官方的例子写法。 看这里: http://aiomysql.readthedocs.org/en/latest/index.html

2.yield from是一个新特性,它允许

 yield from <expr>

作为一个表达式放到任意的generator内。 当这个<expr> 也是一个generator时,yield from 会接收他的返回值。

when the iterator is another generator, the subgenerator is allowed to execute a return statement with a value, and that value becomes the value of the yield from expression.

看这里: https://www.python.org/dev/peps/pep-0234/

3.先安装PyMySQL,再安装aiomysql,import的时候会报错,卸载PyMySQL后再装一下aiomysql就好了。aiomysql requires PyMySQL library.安装的时候会同时自动安装PyMySQL.


  • 1

Reply