Python 64位不存储与32位python一样长的字符串 [英] Python 64 bit not storing as long of string as 32 bit python

查看:24
本文介绍了Python 64位不存储与32位python一样长的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台电脑,都运行 64 位 Windows 7.一台机器有 python 32 位,一台运行 python 64 位.两台机器都有 8GB 的​​内存.

I have two computers, both running 64-bit Windows 7. One machine has python 32-bit, one is running python 64-bit. Both machines have 8GB of RAM.

我正在使用 BeautifulSoup 抓取网页,但在我的 python64 机器上遇到了问题.我已经能够弄清楚我的 len(str(BeautifulSoup(request.get(http://www.sampleurl.com).text))) 在 64 位中的输出仅返回92520 个字符,但在我的 python32 位机器上的同一个静态站点上,它返回 135000 个字符.

I'm using BeautifulSoup to scrape a webpage, but I've been running into issues on my python64 machine. I've been able to figure out that the output of my len(str(BeautifulSoup(request.get(http://www.sampleurl.com).text))) in 64bit is only returning 92520 characters but on the same, static, site on my python32-bit machine, it's returning 135000 characters.

过去在我的 python64 位机器上的某个时候,我有 python32 位,但卸载它以安装 python64 位,因为我在使用 pip install 安装 scipy 时遇到问题(事实证明这不是问题).

At some point in the past on my python64-bit machine I had python32-bit, but uninstalled it to install python64-bit because I was having issues installing scipy using pip install (turns out that wasn't the issue).

无论如何,我不确定为什么我的 64 位 python 机器没有返回整个 html 字符串,我想知道是否有人可以帮助我了解发生了什么以及如何修复它.

Anyway, I'm unsure as to why my 64bit python machine isn't returning the entire html string and I was wondering if anyone can help me understand what is going on and how can I fix it.

推荐答案

这不是 32 位/64 位问题.您很可能是解析器问题;例如,一台机器使用 lxmlhtml.parser 在另一台机器上.

This is not a 32bit / 64bit issue. You are most likely a parser issue; one machine using lxml vs. html.parser on the other, for example.

不同的解析器对损坏的 HTML 的处理方式不同,lxml 仅在安装时是默认值.

Different parsers deal differently with broken HTML, and lxml is the default only when installed.

参见示例:

在两台机器上运行 import lxml 进行验证.当您将一台机器上的 Python 安装替换为 64 位版本时,您可能没有包含兼容的 lxml 版本.

Run import lxml on both machines to verify. When you replaced your Python installation on one machine with a 64-bit version, you likely didn't include a compatible lxml version.

这篇关于Python 64位不存储与32位python一样长的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆