TA的每日心情 | 郁闷 2018-7-1 09:34 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]初来乍到
|
为了让自己远在单位的树莓派在外网IP变化后,向指定邮箱发送最新的IP地址,自己写了个sendmail.py(其实也算不上自己写的,在网上抄的),代码在电脑Python 2.7上运行正常,但是在树莓派上运行却出错了(开始运行是好的,问题就出在这里,感觉昨天代码正常,今天却提示错误),出错的代码就三句:
from json import load
from urllib2 import urlopen
print load(urlopen('https://jsonip.com'))
运行环境树莓派3B+ CentOS+Python 2.7
运行后提示错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1258, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python2.7/urllib2.py", line 1214, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 22] Invalid argument>
请各位帮忙看看,现在单独运行这段代码都不行,而昨天是正常的,树莓派重启也是如此。
|
|