考试报名
考试报名
考试内容
考试大纲
在线客服
返回顶部

备考刷题,请到

CDA认证小程序

下列导入第三方库的语法错误的是( )
A. import math
B. import math as mt
C. from math import *
D. from * import math
上一题
下一题
收藏
点赞
评论
题目解析
题目评论(0)

答案是 D: `from * import math`。

分析:

A: `import math` 是正确的语法,用于导入 Python 标准库中的 `math` 模块。

B: `import math as mt` 也是正确的语法,它导入 `math` 模块并将其重命名为 `mt`,这样可以通过 `mt` 来访问 `math` 模块的功能。

C: `from math import *` 是正确的语法,它从 `math` 模块中导入所有的公共属性和方法。不过,使用 `import *` 通常不被推荐,因为它可能导致命名空间污染,使得代码的可读性和可维护性降低。

D: `from * import math` 是错误的语法。在 Python 中,`from ... import ...` 语句用于从一个模块中导入特定的属性或方法,星号 `*` 不能用作模块名或用于导入特定的名称。正确的用法是指定一个模块名或具体的名称,而不是使用 `*`。