![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python学习
Aseveng
这个作者很懒,什么都没留下…
展开
-
python问题:IndentationError:expected an indented block错误解决
转自:http://blog.csdn.net/neilhappy/article/details/7724959Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。在编译时会出现这样的错IndentationError:ex转载 2017-07-03 18:25:35 · 3623 阅读 · 0 评论 -
python 爬取淘宝信息
import requestsimport redef getHtmlText(url): try: r=requests.get(url,timeout=30) r.raise_for_status() r.encoding=r.apparent_encoding return r.text except: print("11")def parsePage(il原创 2017-08-06 13:58:21 · 1207 阅读 · 0 评论 -
BeautifulSoup
https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html#id4 官方文档转载 2017-08-12 22:17:54 · 243 阅读 · 0 评论 -
python 爬取 最好大学网 的大学排名
import requestsimport bs4def getHtmlText(url): try: r=requests.get(url) r.raise_for_status()#失败会抛出异常 进入except r.encoding=r.apparent_encoding return r.text exc原创 2017-08-01 21:02:12 · 697 阅读 · 0 评论 -
python ValueError: cannot switch from automatic field numbering to manual field specification
ValueError: cannot switch from automatic field numbering to manual field specification此问题是format()函数 前面大括号里 没写 数字 对应后面的 ()的顺序的值tplt="{:^10}\t{:{3}^8}\t{:^10}" print(tplt.format("排名","学原创 2017-08-01 20:37:50 · 14547 阅读 · 1 评论 -
Python BeautifuSoup 库 mooc 中国大学学习
用pip 安装BeautifulSoup库应用BeautifulSoup以http://www.python123.io/ws/demo.html 为例子from bs4 import BeautifulSoupimport requestsr=requests.get("http://www.python123.io/ws/demo.html")demo=r.text转载 2017-08-07 16:39:32 · 341 阅读 · 0 评论 -
MOOC 中国大学 python爬取股票信息
#该程序先从东方财富网爬取股票列表 然后在从百度股票的找出对应股票的信息import requestsfrom bs4 import BeautifulSoupimport tracebackimport re def getHTMLText(url, code="utf-8"): try: r = requests.get(url) r.rai转载 2017-08-07 16:34:18 · 1044 阅读 · 1 评论 -
python 画等边三角形
import turtledef main(): turtle.seth(0) psize=1 turtle.pensize(psize) turtle.fd(100) turtle.seth(120) turtle.fd(100) turtle.seth(240) turtle.fd(100) turt原创 2017-07-07 17:12:02 · 13304 阅读 · 0 评论 -
python eval()
转:www.cnblogs.com/dadadechengzi/p/6149930.htmlpython eval() eval(expression, globals=None, locals=None) --- 官方文档中的解释是,将字符串str当成有效的表达式来求值并返回计算结果。globals和locals参数是可选的,如果提供了globals参数,那么它必须是di转载 2017-07-07 16:40:02 · 857 阅读 · 0 评论 -
Java 异常注意事项
/*异常的注意事项:1、子类在覆盖父类方法是,父类的方法如果抛出了异常那么子类的方法只能抛出父类的异常 或者该异常的子类2、如果父类抛出多个异常,那么子类只能抛出父类异常的子集简单说: 子类覆盖父类只能抛出父类的异常或者子类或者子集注意: 如果父类的方法没有抛出异常,那么子类覆盖时绝对不能抛异常 就只能tryinterface Inter{ void function();原创 2017-08-15 20:56:03 · 288 阅读 · 0 评论