google了一些,好像是python或部署的原因,但是有這些錯(cuò)誤信息: Traceback (most recent call last):
... File "/usr/local/lib/python2.7/urllib.py", line 84, in urlopen return opener.open(url) File "/usr/local/lib/python2.7/urllib.py", line 205, in open return getattr(self, name)(url) File "/usr/local/lib/python2.7/urllib.py", line 356, in open_http return self.http_error(url, fp, errcode, errmsg, headers) File "/usr/local/lib/python2.7/urllib.py", line 369, in http_error
result = method(url, fp, errcode, errmsg, headers) File "/usr/local/lib/python2.7/urllib.py", line 663, in http_error_301 return self.http_error_302(url, fp, errcode, errmsg, headers, data) File "/usr/local/lib/python2.7/urllib.py", line 632, in http_error_302
data) File "/usr/local/lib/python2.7/urllib.py", line 659, in redirect_internal return self.open(newurl) File "/usr/local/lib/python2.7/urllib.py", line 205, in open return getattr(self, name)(url) File "/usr/local/lib/python2.7/urllib.py", line 356, in open_http return self.http_error(url, fp, errcode, errmsg, headers) File "/usr/local/lib/python2.7/urllib.py", line 369, in http_error
result = method(url, fp, errcode, errmsg, headers) File "/usr/local/lib/python2.7/urllib.py", line 694, in http_error_401 return getattr(self,name)(url, realm) File "/usr/local/lib/python2.7/urllib.py", line 758, in retry_http_basic_auth
user, passwd = self.get_user_passwd(host, realm, i) File "/usr/local/lib/python2.7/urllib.py", line 787, in get_user_passwd
user, passwd = self.prompt_user_passwd(host, realm) File "/usr/local/lib/python2.7/urllib.py", line 796, in prompt_user_passwd
host))
EOFError: EOF when reading a line這是權(quán)限問題?到底是什么問題呢?
2 回答

GCT1015
TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊
如果想繼續(xù)使用urllib的話,可以使用FancyURLopener
并且自己定義一個(gè)prompt_user_password
方法。
urllib的易用性的確是經(jīng)常為人所詬病.. 所以另外一個(gè)辦法是,換用一個(gè)更好用的庫。我推薦python-requests
。用這個(gè)庫就可以這么寫:
>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))>>> r.status_code200>>> r.headers['content-type']'application/json; charset=utf8'>>> r.encoding'utf-8'>>> r.textu'{"type":"User"...'

回首憶惘然
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊
安裝SublimeREPL,然后編譯python文件的時(shí)候,可以選擇【Tools】——【sublimeREPL】——【python】——【Python – RUN current file】即可提示用戶輸入。應(yīng)該可以解決sublime下面使用raw_input函數(shù)報(bào)錯(cuò)的問題。
添加回答
舉報(bào)
0/150
提交
取消