Python URL 字符
总的来说,我对 Python 和编码还很陌生,但我已经取得了一些长足的进步。
我可以通过 API 从网络上获取一些数据,结果应该是一个字符串。不过,我看到的是一些实例,例如“&”和“"”。(我修改了字符集,以便它可以正确打印到屏幕上)
我认为有一种方法可以清理这个字符串并删除字符,使其看起来像在计算机屏幕上一样 我尝试搜索 urldecoding,但不可否认,我什至不知道这是否是解决方案
。 !
非常感谢,
布洛克
I really new to Python and coding in general, but I have been making some good strides.
I am able to pull some data off of the web through an API, and the result should be a string. What I am seeing though, are some instances such as "& amp;"" and " "". (I modified the character sets so it would print properly to the screen)
I figure there is a way to clean this string and remove the characters such that it looks like it does on a computer screen. I tried searching for urldecoding, but admittedly I dont even know if that is the solution.
Any help on how to remove these "extra" characters and produce a readable string will be greatly appreciated!
Many thanks in advance,
Brock
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
xml.sax.saxutils.unescape(数据[,实体]) :对数据字符串中的“&”、“<”和“>”进行转义。
您可以通过传递字典作为可选实体参数来取消转义其他数据字符串。键和值必须都是字符串;每个键将被替换为其对应的值。即使提供了实体,“&”、“<”和“>”始终不会转义。
xml.sax.saxutils.unescape(data[, entities]): Unescape '&', '<', and '>' in a string of data.
You can unescape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value. '&', '<', and '>' are always unescaped, even if entities is provided.