我正在尝试使用pip为python安装Scrapy软件包(以及其他软件包).我已经尝试使用python 3和python 2进行安装,我已经安装/升级了setuptools,如下所示:$ pip3 install --upgrade setuptools我尝试使用如下--trusted-host选项:$ pip3 install --trusted-host pypi.python.org Scrapy.但是当我跑步时,我总是得到相同的错误信息$ pip3 install Scrapy.完整的输出是这样的:
Collecting Scrapy
Using cached Scrapy-1.3.2-py2.py3-none-any.whl
Collecting PyDispatcher>=2.0.5 (from Scrapy)
Using cached PyDispatcher-2.0.5.tar.gz
Collecting service-identity (from Scrapy)
Using cached service_identity-16.0.0-py2.py3-none-any.whl
Collecting pyOpenSSL (from Scrapy)
Using cached pyOpenSSL-16.2.0-py2.py3-none-any.whl
Collecting w3lib>=1.15.0 (from Scrapy)
Using cached w3lib-1.17.0-py2.py3-none-any.whl
Collecting parsel>=1.1 (from Scrapy)
Using cached parsel-1.1.0-py2.py3-none-any.whl
Collecting queuelib (from Scrapy)
Using cached queuelib-1.4.2-py2.py3-none-any.whl
Requirement already satisfied: six>=1.5.2 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from Scrapy)
Collecting Twisted>=13.1.0 …Run Code Online (Sandbox Code Playgroud) 我试图将表情符号转换为python 3中的Unicode.例如,我将使用表情符号,并希望获得相应的unicode"U + 1F600".同样我想将'U + 1F600'转换回来.现在我已经阅读了文档并尝试了几个选项,但是pythons行为让我感到困惑.
>>> x = ''
>>> y = x.encode('utf-8')
>>> y
b'\xf0\x9f\x98\x80'
Run Code Online (Sandbox Code Playgroud)
表情符号被转换为字节对象.
>>> z = y.decode('utf-8')
>>> z
''
Run Code Online (Sandbox Code Playgroud)
将字节对象转换回表情符号,到目前为止一直很好.
现在,为表情符号取unicode:
>>> c = '\U0001F600'
>>> d = c.encode('utf-8')
>>> d
>>> b'\xf0\x9f\x98\x80'
Run Code Online (Sandbox Code Playgroud)
这会再次打印出字节编码.
>>> d.decode('utf-8')
>>> ''
Run Code Online (Sandbox Code Playgroud)
这会再次打印出表情符号.我真的无法弄清楚如何只在Unicode和表情符号之间进行转换.
我正在玩BeautifulSoup 4,我有这个HTML代码:
</tr>
<tr>
<td id="freistoesse">Giraffe</td>
<td>14</td>
<td>7</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我想匹配<td>标签之间的两个值,所以这里是14和7.
我试过这个:
giraffe = soup.find(text='Giraffe').findNext('td').text
Run Code Online (Sandbox Code Playgroud)
但这只是匹配14.如何使用此功能匹配这两个值?
我想在Haskell中将Maybe Int转换为Int,如下所示:
convert :: Maybe Int -> Int
convert mx = case mx of
Just x -> x
Nothing -> error "error message"
Run Code Online (Sandbox Code Playgroud)
当我编译它时,Haskell告诉我:parse error on input 'Nothing'.
我需要这个,因为我想从Data.List模块中使用elem.Index函数获取列表中元素的索引,然后在take函数上使用此索引.我的问题是elemIndex返回a Maybe Int,但take需要一个Int.
python ×3
emoji ×1
formatting ×1
haskell ×1
macos ×1
maybe ×1
parse-error ×1
pip ×1
python-2.7 ×1
ssl ×1
unicode ×1