常见问题汇总

1、不加

if __name__ == "__main__":

 报错
IndentationError: unexpected indent

 

eg:

# -*- coding:utf-8 -*-

import requests

r = requests.get('http://www.cnblogs.com/harbin-charles')
code = r.status_code
print(code)

2、for循环的机理(易出错):循环取值不同导致结果也不同

 

 按索引顺序去取值

 

3、在python代码里可以用r.content这个方法,content会自动解码gzip和deflate
posted on 2017-09-20 18:14  Charles.luo  阅读(168)  评论(0编辑  收藏  举报