作者milkdicky (家政教育学系班代)
看板Python
标题[问题] 抓网页最後会输出什麽样的东西?
时间Sun Oct 13 22:33:36 2013
>>> import urllib.request as url
>>> fh = url.urlopen('
http://www.tzuchi.org.tw')
>>> content = fh.read().decode('utf-8')
>>> with open('test','w') as fd:
... fd.write(content)
File "<stdin>", line 2
fd.write(content)
^
IndentationError: expected an indented block
>>> fd.write(content)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'fd' is not defined
>>>
请问IndentationError是什麽意思?是慈济网站阻挡下来了吗?
--
http://dicky.twbbs.org/
╔O ╔╗+ ╭╮O ╔╗╔╗ ★ O
║║ ║║ ╰╯。 O║║║。O
║║ ║║╔═O╦╦═╗O║╚╝╠═╦╦╗
║║☆║╚╣║║│║╩╣ ╚╗╔╣║║║║
╚╝ O═╩═╩═╩═╝★ ╚╝╚═╩═O
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.122.36.82
1F:推 tiefblau:...就indent错阿= = 写py一定要好好缩排 10/13 22:40
2F:推 alex0914:少个tab... 10/13 22:58
3F:→ milkdicky:谢谢楼上两位。 10/13 23:04
4F:→ lc85301:XDDD,合理怀疑你没选个会自动缩排的工具lol 10/14 00:02
5F:→ ck574b027:看起来就是用内建 cmd line 打的啊 10/14 00:15
6F:→ milkdicky:我是直接在终端机打的,请问会自动缩排的工具有哪些? 10/14 08:04
7F:→ ming1053:ipython 10/14 08:48