Open twz915 opened 9 years ago
@twz915 My test:
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def foo():
from sys import *
SyntaxError: import * only allowed at module level
>>>
这个在 python2.7 里边也是这样啊
On Tue, Feb 2, 2016 at 8:40 AM, myd7349 notifications@github.com wrote:
@twz915 https://github.com/twz915 My test:
def foo(): from sys import SyntaxError: import \ only allowed at module level>>>
— Reply to this email directly or view it on GitHub https://github.com/qyuhen/book/issues/36#issuecomment-178274501.
@shellexy 对的,这不是Python 2.7 和 Python 3.x 的不同,它们是一样的。还有为什么要在函数中引入,这是不推荐的
@myd7349 你这个是语法错误啊
from . import * 在 Python3中还是可以使用的,符合语法规则,我测试的 Python 3.5
PDF 87 页