`from x import y` vs. `from x.y import *`

前端 未结 2 726
迷失自我
迷失自我 2021-01-02 21:33

What is the difference between these two lines?

from PyQt4 import QtGui
from PyQt4.QtGui import *

The first line is \"import QtGui class fr

2条回答
  •  再見小時候
    2021-01-02 22:12

    Packages may export more than one thing. The difference is that the first line imports a single object from the package, the second imports everything. If the package you are importing only exports one thing, the two are synonymous.

提交回复
热议问题