亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python json,不必要的斜杠

Python json,不必要的斜杠

慕絲7291255 2021-04-04 12:55:32
我正在創建一個簡單的服務器端應用程序,我使用內置的模塊“ json”來創建客戶端的答案。if isinstance(obj, (list, tuple)):    return json.dumps({key: [o.to_json() for o in obj if                             isinstance(o, JsonAble)]}, ensure_ascii=False)我的班級在哪里class ArtistSearchResult(JsonAble):    def to_json(self):        return json.dumps({'name': self.name, 'descr': self.descr,                           "url": self.url, 'genres': self.genres},                          allow_nan=False, ensure_ascii=False)它可以工作,但是作為響應,我有一個不必要的斜線:{"responce": ["{\"url\": \"/music/Lindsey+Buckingham\", \"genres\": [\"singer-songwriter\"], \"name\": \"Lindsey Buckingham\", \"descr\": \"Lindsey Adams Buckingham (born October 3, 1949) is an American guitarist, singer, composer and producer, most notable for being the...…read more\"}", "{\"url\": \"/music/Lindsey+Stirling\", \"genres\": [\"violin\"], \"name\": \"Lindsey Stirling\", \"descr\": \"Lindsey Stirling (b. 21 September 1986 in Orange County, California) is a violinist, dancer and composer based in Utah.…read more\"}", "{\"url\": \"/music/Graham+Lindsey\", \"genres\": [\"alt-country\"], \"name\": \"Graham Lindsey\", \"descr\": \"Graham Lindsey is a performing songwriter, an americana singer of subtle, stark ballads and waltzes of love and murder. A member of the...…read more\"}", "{\"url\": \"/music/Lindsey+Haun\", \"genres\": [\"country\"], \"name\": \"Lindsey Haun\", \"descr\": \"Lindsey Haun (born 為什么它們出現在我的答案中?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 518 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號