Python-import xx 和 from xx import xx 的区别

1.import xx :导入模块,在使用的时候需要 “ 模块.函数 ”来使用

例如:

1 import math
2 math.sqr(5)

 

 2.from xx import xx 和 from xx import *

  这两个本质没有区别,都是从其它模块里面导入函数。但是唯一的区别就是* 能够导入某个模块的所有东西。

  而from xx import xx 在使用的时候可以直接使用xx 函数。

例如

from test import test_
from test import *

test_()
test_()

 

posted @ 2022-11-23 15:48  许个未来—  阅读(285)  评论(0)    收藏  举报