from … import OR import … as for modules

后端 未结 6 455
萌比男神i
萌比男神i 2020-11-29 02:57

Should I use

from foo import bar

OR

import foo.bar as bar

when importing a module and an

6条回答
  •  情深已故
    2020-11-29 03:15

    You can use as to rename modules suppose you have two apps that have views and you want to import them

    from app1 import views as views1
    from app2 import views as views2
    

    if you want multiple import use comma separation

    >>> from datetime import date as d, time as t
    >>> d
    
    >>> t
    
    

提交回复
热议问题