[問題] 抓網頁最後會輸出什麼樣的東西?

看板Python作者 (家政教育學系班代)時間11年前 (2013/10/13 14:33), 編輯推噓2(205)
留言7則, 6人參與, 最新討論串1/1
>>> 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

10/13 22:40, , 1F
...就indent錯阿= = 寫py一定要好好縮排
10/13 22:40, 1F

10/13 22:58, , 2F
少個tab...
10/13 22:58, 2F

10/13 23:04, , 3F
謝謝樓上兩位。
10/13 23:04, 3F

10/14 00:02, , 4F
XDDD,合理懷疑你沒選個會自動縮排的工具lol
10/14 00:02, 4F

10/14 00:15, , 5F
看起來就是用內建 cmd line 打的啊
10/14 00:15, 5F

10/14 08:04, , 6F
我是直接在終端機打的,請問會自動縮排的工具有哪些?
10/14 08:04, 6F

10/14 08:48, , 7F
ipython
10/14 08:48, 7F
文章代碼(AID): #1IMgz5vz (Python)