Python imports across modules and global variables

后端 未结 4 671
遇见更好的自我
遇见更好的自我 2020-12-19 10:00

I have a question which seems to be rather fundamental but I can\'t seem to find any help on this anywhere.

file_a.py >>

from xyz import XYZ
class A:
         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 10:32

    import file_a
    from file_a import A
    

    I think the problem is: you do not import XYZ really!

    from fila_a import * 
    

    can solve your problem,but it is not a good way~~~

    you can write this in file_b:

    from file_a import XYZ
    

    It is done?

提交回复
热议问题