python 解决IndentationError: unexpected unindent的报错!和通用代码框架,import requests def getHTMLText(url)...的解释
python报错IndentationError:expectedanindentedblock。解决办法很简单,是脚本缩进的问题,检查脚本缩进是否有空格和tab混用的情况或者是缩进明显不对的情况。通用代码框架:importrequestsdefgetHTMLText(url):try:#n个空格缩进(n!=0)r=requests.get(url,timeout=30)#2n个空格缩进(n!=0