首页 > 试题广场 >

在Python中导入模块中的对象有哪几种方式?

[问答题]

在Python中导入模块中的对象有哪几种方式?

  1. import module_a #导入
  2. from module import xx
  3. from module.xx.xx import xx as rename #导入后重命令
  4. from module.xx.xx import * #导入一个模块下的所有方法,不建议使用
  5. module_a.xxx #调用
发表于 2019-11-20 19:01:46 回复(0)

常用的有三种方式,分别为

import模块名[as别名]

from模块名import对象名[ as别名]

from math import *

发表于 2017-12-28 15:37:59 回复(0)