try: r = requests.get('http://www.baidu.com',timeout=30) r.raise_for_status() r.encoding = r.apparent_encoding return r.text except: return '我怎么知道又错了' SyntaxError: 'return' outside function
import requests try: r = requests.get('http://www.baidu.com',timeout=30) r.raise_for_status() r.encoding = r.apparent_encoding except: print('我怎么知道又错了') print(r.text) return是在函数中返回
return needs to be used inside a function
return can generally only be used in functions.
return needs to be used inside a function
return can generally only be used in functions.