課程
/后端開發(fā)
/Python
/Python開發(fā)簡(jiǎn)單爬蟲
我的這一行怎么有問(wèn)題的呢print response1.getcode()
2018-07-19
源自:Python開發(fā)簡(jiǎn)單爬蟲 5-3
正在回答
我能不能弱弱的問(wèn)一句,這圖片是咋整的?截屏?可以先看一下“搭建可靠的mongoDB集群”
使用的是python3而且print語(yǔ)句也是添加了括號(hào),代碼與報(bào)錯(cuò)如下
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def print_scores(**kw):
? ? print('? ? ? Name? Score')
? ? print('------------------')
? ? for name, score in kw.items():
? ? ? ? print('%10s? %d' % (name, score))
? ? print()
print_scores(Adam=99, Lisa=88, Bart=77)
data = {
? ? 'Adam Lee': 99,
? ? 'Lisa S': 88,
? ? 'F.Bart': 77
}
print_scores(**data)
def print_info(name, *, gender, city='Beijing', age):
? ? print('Personal Info')
? ? print('---------------')
? ? print('? ?Name: %s' % name)
? ? print(' Gender: %s' % gender)
? ? print('? ?City: %s' % city)
? ? print('? ? Age: %s' % age)
print_info('Bob', gender='male', age=20)
print_info('Lisa', gender='female', city='Shanghai', age=18)
你用的 應(yīng)該是是python2還是python3?
#原因,我猜你用的是Python3 python3和python2是有區(qū)別的
# python3 的print( )方法 需要家括號(hào)
我的環(huán)境是python3
下面是我的代碼,希望對(duì)你有幫助
import urllib.request
import http.cookiejar
url = "http://www.baidu.com"
print('第一種方法')
response1 = urllib.request.urlopen(url)
print(response1.getcode())
print(len(response1.read()))
舉報(bào)
本教程帶您解開python爬蟲這門神奇技術(shù)的面紗
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2022-03-27
我能不能弱弱的問(wèn)一句,這圖片是咋整的?截屏?可以先看一下“搭建可靠的mongoDB集群”
2019-07-05
使用的是python3而且print語(yǔ)句也是添加了括號(hào),代碼與報(bào)錯(cuò)如下
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def print_scores(**kw):
? ? print('? ? ? Name? Score')
? ? print('------------------')
? ? for name, score in kw.items():
? ? ? ? print('%10s? %d' % (name, score))
? ? print()
print_scores(Adam=99, Lisa=88, Bart=77)
data = {
? ? 'Adam Lee': 99,
? ? 'Lisa S': 88,
? ? 'F.Bart': 77
}
print_scores(**data)
def print_info(name, *, gender, city='Beijing', age):
? ? print('Personal Info')
? ? print('---------------')
? ? print('? ?Name: %s' % name)
? ? print(' Gender: %s' % gender)
? ? print('? ?City: %s' % city)
? ? print('? ? Age: %s' % age)
? ? print()
print_info('Bob', gender='male', age=20)
print_info('Lisa', gender='female', city='Shanghai', age=18)
2018-07-19
你用的 應(yīng)該是是python2還是python3?
#原因,我猜你用的是Python3 python3和python2是有區(qū)別的
# python3 的print( )方法 需要家括號(hào)
我的環(huán)境是python3
下面是我的代碼,希望對(duì)你有幫助
import urllib.request
import http.cookiejar
url = "http://www.baidu.com"
print('第一種方法')
response1 = urllib.request.urlopen(url)
print(response1.getcode())
print(len(response1.read()))