[英]How to read csv files (with special characters) in Python? How can I decode the text data? Read encoded text from file and convert to string
[英]How to decode JSON special characters in string in python?
这是我的代码:
import requests
import json
r = requests.get(url="news_api_here")
json_data = json.loads(r.content)
for i in range(len(json_data)):
title = str(json_data[i]["headline"])
print(title)
给定标题的 output 是这样的:
Development%2c Expansion%2c Merger%2c Acquisition%2c New Product Launches%2c and Pricing Analysis%3c%2fa%3e%3c
如何将字符串解码为正确的字符?
使用请求的库unquote()
import requests
requests.utils.unquote(title)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.