我正在創建一個簡單的服務器端應用程序,我使用內置的模塊“ 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 為什么它們出現在我的答案中?
添加回答
舉報
0/150
提交
取消