Skip to content

Instantly share code, notes, and snippets.

@taojy123
Last active September 1, 2016 07:11
Show Gist options
  • Save taojy123/1b76c6a90f791b10b2a6936cd95ee9e8 to your computer and use it in GitHub Desktop.
Save taojy123/1b76c6a90f791b10b2a6936cd95ee9e8 to your computer and use it in GitHub Desktop.
Python 跨文件跨进程使用全局变量
abc = None
cba = None
def set_abc(value):
global abc
abc = value
def get_abc():
global abc
return abc
import globalvar
import threading
import time
import t
globalvar.set_abc('123')
globalvar.cba = '321'
t1 = threading.Thread(target=t.show_data)
t1.setDaemon(True)
t1.start()
time.sleep(1)
print 'finish!'
import globalvar
def get_data():
print globalvar.get_abc()
print globalvar.cba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment