call a function in python script then check if condition
问题 I have this function: def ContentFunc(): storage = StringIO() c = pycurl.Curl() c.setopt(c.URL, url) c.setopt(c.WRITEFUNCTION, storage.write) c.perform() c.close() content = storage.getvalue() while True: ContentFunc() if "word" in content: out = open('/tmp/test', 'a+') I want to append content from content = storage.getvalue() . But doesn't work. The ERROR: NameError: name 'content' is not defined Can you help me? 回答1: In your function def ContentFunc(): ... content = storage.getvalue() This