Python variable assigned by an outside module is accessible for printing but not for assignment in the target module

后端 未结 2 434
春和景丽
春和景丽 2021-01-24 17:42

I have two files, one is in the webroot, and another is a bootstrap located one folder above the web root (this is CGI programming by the way).

The index file in the web

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-24 18:48

    Don't declare it global, pass it instead and return it if you need to have a new value, like this:

    def initialize(a):
        print('Content-type: text/html\n\n')
        print a
        return 'h'
    
    ----
    
    import bootstrap
    b = bootstrap.initialize('testVar')
    

提交回复
热议问题