将字符串中的unicode字符转换为ISO 88591字符

2024-09-27 07:34:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下字符串:

'\x7B\x22h\x22\x3A\x5B\x7B\x22id\x22\x3A\x22242611\x22,\x22minute\x22\x3A\x222\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.9359999847412109\x22,\x22Y\x22\x3A\x220.534000015258789\x22,\x22xG\x22\x3A\x220.1072189137339592\x22,\x22player\x22\x3A\x22Ari\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222930\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22Head\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Wanderson\x22,\x22lastAction\x22\x3A\x22Chipped\x22\x7D,\x7B\x22id\x22\x3A\x22242612\x22,\x22minute\x22\x3A\x224\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.8059999847412109\x22,\x22Y\x22\x3A\x220.7069999694824218\x22,\x22xG\x22\x3A\x220.021672379225492477\x22,\x22player\x22\x3A\x22Cristian\x20Ram\x5Cu00edrez\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225477\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242613\x22,\x22minute\x22\x3A\x224\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.7780000305175782\x22,\x22Y\x22\x3A\x220.505\x22,\x22xG\x22\x3A\x220.023817993700504303\x22,\x22player\x22\x3A\x22Mauricio\x20Pereyra\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222922\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Viktor\x20Claesson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242614\x22,\x22minute\x22\x3A\x2217\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.9330000305175781\x22,\x22Y\x22\x3A\x220.41\x22,\x22xG\x22\x3A\x220.01863950863480568\x22,\x22player\x22\x3A\x22Ari\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222930\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22Head\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Mauricio\x20Pereyra\x22,\x22lastAction\x22\x3A\x22Aerial\x22\x7D,\x7B\x22id\x22\x3A\x22242617\x22,\x22minute\x22\x3A\x2221\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.710999984741211\x22,\x22Y\x22\x3A\x220.534000015258789\x22,\x22xG\x22\x3A\x220.015956614166498184\x22,\x22player\x22\x3A\x22Ivan\x20Ignatyev\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x226025\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Ari\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242621\x22,\x22minute\x22\x3A\x2231\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.7959999847412109\x22,\x22Y\x22\x3A\x220.4640000152587891\x22,\x22xG\x22\x3A\x220.03898102045059204\x22,\x22player\x22\x3A\x22Viktor\x20Claesson\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225478\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242622\x22,\x22minute\x22\x3A\x2236\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.759000015258789\x22,\x22Y\x22\x3A\x220.3509999847412109\x22,\x22xG\x22\x3A\x220.05237437039613724\x22,\x22player\x22\x3A\x22Mauricio\x20Pereyra\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222922\x22,\x22situation\x22\x3A\x22DirectFreekick\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22Standard\x22\x7D,\x7B\x22id\x22\x3A\x22242624\x22,\x22minute\x22\x3A\x2242\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.919000015258789\x22,\x22Y\x22\x3A\x220.37\x22,\x22xG\x22\x3A\x220.10843519121408463\x22,\x22player\x22\x3A\x22Sergei\x20Petrov\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222920\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Viktor\x20Claesson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242625\x22,\x22minute\x22\x3A\x2248\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.7719999694824219\x22,\x22Y\x22\x3A\x220.385\x22,\x22xG\x22\x3A\x220.023656079545617104\x22,\x22player\x22\x3A\x22Aleksandr\x20Martynovich\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222790\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Yuri\x20Gazinskiy\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242626\x22,\x22minute\x22\x3A\x2249\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.715999984741211\x22,\x22Y\x22\x3A\x220.4879999923706055\x22,\x22xG\x22\x3A\x220.013118931092321873\x22,\x22player\x22\x3A\x22Yuri\x20Gazinskiy\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222929\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Viktor\x20Claesson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242627\x22,\x22minute\x22\x3A\x2254\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.909000015258789\x22,\x22Y\x22\x3A\x220.3529999923706055\x22,\x22xG\x22\x3A\x220.09400425851345062\x22,\x22player\x22\x3A\x22Magomed\x2DShapi\x20Suleymanov\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225926\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Viktor\x20Claesson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242628\x22,\x22minute\x22\x3A\x2254\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.8859999847412109\x22,\x22Y\x22\x3A\x220.31799999237060544\x22,\x22xG\x22\x3A\x220.061035316437482834\x22,\x22player\x22\x3A\x22Magomed\x2DShapi\x20Suleymanov\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225926\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Yuri\x20Gazinskiy\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242629\x22,\x22minute\x22\x3A\x2255\x22,\x22result\x22\x3A\x22Goal\x22,\x22X\x22\x3A\x220.9269999694824219\x22,\x22Y\x22\x3A\x220.46\x22,\x22xG\x22\x3A\x220.523554801940918\x22,\x22player\x22\x3A\x22Magomed\x2DShapi\x20Suleymanov\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225926\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Viktor\x20Claesson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242630\x22,\x22minute\x22\x3A\x2266\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.915\x22,\x22Y\x22\x3A\x220.5420000076293945\x22,\x22xG\x22\x3A\x220.3631550371646881\x22,\x22player\x22\x3A\x22Christian\x20Cueva\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x226799\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Cristian\x20Ram\x5Cu00edrez\x22,\x22lastAction\x22\x3A\x22Cross\x22\x7D,\x7B\x22id\x22\x3A\x22242631\x22,\x22minute\x22\x3A\x2271\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.685\x22,\x22Y\x22\x3A\x220.485\x22,\x22xG\x22\x3A\x220.03188558667898178\x22,\x22player\x22\x3A\x22Cristian\x20Ram\x5Cu00edrez\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225477\x22,\x22situation\x22\x3A\x22DirectFreekick\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22Standard\x22\x7D,\x7B\x22id\x22\x3A\x22242632\x22,\x22minute\x22\x3A\x2272\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.8909999847412109\x22,\x22Y\x22\x3A\x220.4809999847412109\x22,\x22xG\x22\x3A\x220.09532035887241364\x22,\x22player\x22\x3A\x22Sergei\x20Petrov\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x222920\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242634\x22,\x22minute\x22\x3A\x2275\x22,\x22result\x22\x3A\x22Goal\x22,\x22X\x22\x3A\x220.794000015258789\x22,\x22Y\x22\x3A\x220.47900001525878905\x22,\x22xG\x22\x3A\x220.05203503370285034\x22,\x22player\x22\x3A\x22Ivan\x20Ignatyev\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x226025\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242635\x22,\x22minute\x22\x3A\x2277\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.904000015258789\x22,\x22Y\x22\x3A\x220.5\x22,\x22xG\x22\x3A\x220.13627302646636963\x22,\x22player\x22\x3A\x22Viktor\x20Claesson\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225478\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Christian\x20Cueva\x22,\x22lastAction\x22\x3A\x22Chipped\x22\x7D,\x7B\x22id\x22\x3A\x22242637\x22,\x22minute\x22\x3A\x2281\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.8719999694824219\x22,\x22Y\x22\x3A\x220.6840000152587891\x22,\x22xG\x22\x3A\x220.07149235904216766\x22,\x22player\x22\x3A\x22Cristian\x20Ram\x5Cu00edrez\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225477\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Mauricio\x20Pereyra\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242638\x22,\x22minute\x22\x3A\x2282\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.895\x22,\x22Y\x22\x3A\x220.6329999923706054\x22,\x22xG\x22\x3A\x220.10822572559118271\x22,\x22player\x22\x3A\x22Ivan\x20Ignatyev\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x226025\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Magomed\x2DShapi\x20Suleymanov\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242639\x22,\x22minute\x22\x3A\x2286\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.7680000305175781\x22,\x22Y\x22\x3A\x220.6519999694824219\x22,\x22xG\x22\x3A\x220.019864005967974663\x22,\x22player\x22\x3A\x22Viktor\x20Claesson\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x225478\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242640\x22,\x22minute\x22\x3A\x2287\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.795\x22,\x22Y\x22\x3A\x220.7330000305175781\x22,\x22xG\x22\x3A\x220.01853240840137005\x22,\x22player\x22\x3A\x22Christian\x20Cueva\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x226799\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Sergei\x20Petrov\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D\x5D,\x22a\x22\x3A\x5B\x7B\x22id\x22\x3A\x22242615\x22,\x22minute\x22\x3A\x2218\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.89\x22,\x22Y\x22\x3A\x220.4279999923706055\x22,\x22xG\x22\x3A\x220.3485192060470581\x22,\x22player\x22\x3A\x22Andrei\x20Panyukov\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x226138\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Nikolay\x20Dimitrov\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242616\x22,\x22minute\x22\x3A\x2218\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.8719999694824219\x22,\x22Y\x22\x3A\x220.4\x22,\x22xG\x22\x3A\x220.30197691917419434\x22,\x22player\x22\x3A\x22Nikolay\x20Dimitrov\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x225496\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22Rebound\x22\x7D,\x7B\x22id\x22\x3A\x22242618\x22,\x22minute\x22\x3A\x2222\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.86\x22,\x22Y\x22\x3A\x220.5\x22,\x22xG\x22\x3A\x220.06458419561386108\x22,\x22player\x22\x3A\x22Eric\x20Bicfalvi\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x225483\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Othman\x20El\x20Kabir\x22,\x22lastAction\x22\x3A\x22Cross\x22\x7D,\x7B\x22id\x22\x3A\x22242619\x22,\x22minute\x22\x3A\x2224\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.8030000305175782\x22,\x22Y\x22\x3A\x220.6179999923706054\x22,\x22xG\x22\x3A\x220.035318903625011444\x22,\x22player\x22\x3A\x22Eric\x20Bicfalvi\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x225483\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242620\x22,\x22minute\x22\x3A\x2229\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.81\x22,\x22Y\x22\x3A\x220.585\x22,\x22xG\x22\x3A\x220.04518153518438339\x22,\x22player\x22\x3A\x22Othman\x20El\x20Kabir\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x226587\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Andrei\x20Panyukov\x22,\x22lastAction\x22\x3A\x22HeadPass\x22\x7D,\x7B\x22id\x22\x3A\x22242623\x22,\x22minute\x22\x3A\x2241\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.7580000305175781\x22,\x22Y\x22\x3A\x220.575\x22,\x22xG\x22\x3A\x220.022277826443314552\x22,\x22player\x22\x3A\x22Othman\x20El\x20Kabir\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x226587\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Nikolay\x20Dimitrov\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242633\x22,\x22minute\x22\x3A\x2274\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.750999984741211\x22,\x22Y\x22\x3A\x220.35700000762939454\x22,\x22xG\x22\x3A\x220.01709834299981594\x22,\x22player\x22\x3A\x22Nikolay\x20Dimitrov\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x225496\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Eric\x20Bicfalvi\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x22242636\x22,\x22minute\x22\x3A\x2279\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.8530000305175781\x22,\x22Y\x22\x3A\x220.3920000076293945\x22,\x22xG\x22\x3A\x220.042678408324718475\x22,\x22player\x22\x3A\x22Yuri\x20Bavin\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x223085\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x22242641\x22,\x22minute\x22\x3A\x2292\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.705999984741211\x22,\x22Y\x22\x3A\x220.534000015258789\x22,\x22xG\x22\x3A\x220.01331254467368126\x22,\x22player\x22\x3A\x22Eric\x20Bicfalvi\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x225483\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222018\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x229071\x22,\x22h_team\x22\x3A\x22FC\x20Krasnodar\x22,\x22a_team\x22\x3A\x22Ural\x22,\x22h_goals\x22\x3A\x222\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222018\x2D12\x2D02\x2011\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Andrey\x20Egorychev\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D\x5D\x7D'

我想将此字符串转换为以下JSON对象:

{"h":[{"id":"242611","minute":"2","result":"MissedShots","X":"0.9359999847412109","Y":"0.534000015258789","xG":"0.1072189137339592","player":"Ari","h_a":"h","player_id":"2930","situation":"OpenPlay","season":"2018","shotType":"Head","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":"Wanderson","lastAction":"Chipped"},{"id":"242612","minute":"4","result":"SavedShot","X":"0.8059999847412109","Y":"0.7069999694824218","xG":"0.021672379225492477","player":"Cristian Ramirez","h_a":"h","player_id":"5477","situation":"OpenPlay","season":"2018","shotType":"LeftFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":null,"lastAction":"None"},{"id":"242613","minute":"4","result":"SavedShot","X":"0.7780000305175782","Y":"0.505","xG":"0.023817993700504303","player":"Mauricio Pereyra","h_a":"h","player_id":"2922","situation":"OpenPlay","season":"2018","shotType":"RightFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":"Viktor Claesson","lastAction":"Pass"},{"id":"242614","minute":"17","result":"MissedShots","X":"0.9330000305175781","Y":"0.41","xG":"0.01863950863480568","player":"Ari","h_a":"h","player_id":"2930","situation":"FromCorner","season":"2018","shotType":"Head","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":"Mauricio Pereyra","lastAction":"Aerial"},{"id":"242617","minute":"21","result":"SavedShot","X":"0.710999984741211","Y":"0.534000015258789","xG":"0.015956614166498184","player":"Ivan Ignatyev","h_a":"h","player_id":"6025","situation":"OpenPlay","season":"2018","shotType":"RightFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":"Ari","lastAction":"Pass"},{"id":"242621","minute":"31","result":"MissedShots","X":"0.7959999847412109","Y":"0.4640000152587891","xG":"0.03898102045059204","player":"Viktor Claesson","h_a":"h","player_id":"5478","situation":"OpenPlay","season":"2018","shotType":"RightFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":null,"lastAction":"None"},{"id":"242622","minute":"36","result":"MissedShots","X":"0.759000015258789","Y":"0.3509999847412109","xG":"0.05237437039613724","player":"Mauricio Pereyra","h_a":"h","player_id":"2922","situation":"DirectFreekick","season":"2018","shotType":"LeftFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":null,"lastAction":"Standard"},{"id":"242624","minute":"42","result":"BlockedShot","X":"0.919000015258789","Y":"0.37","xG":"0.10843519121408463","player":"Sergei Petrov","h_a":"h","player_id":"2920","situation":"OpenPlay","season":"2018","shotType":"RightFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":"Viktor Claesson","lastAction":"Pass"},{"id":"242625","minute":"48","result":"MissedShots","X":"0.7719999694824219","Y":"0.385","xG":"0.023656079545617104","player":"Aleksandr Martynovich","h_a":"h","player_id":"2790","situation":"OpenPlay","season":"2018","shotType":"RightFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural","h_goals":"2","a_goals":"0","date":"2018-12-02 11:00:00","player_assisted":"Yuri Gazinskiy","lastAction":"Pass"},{"id":"242626","minute":"49","result":"MissedShots","X":"0.715999984741211","Y":"0.4879999923706055","xG":"0.013118931092321873","player":"Yuri Gazinskiy","h_a":"h","player_id":"2929","situation":"OpenPlay","season":"2018","shotType":"RightFoot","match_id":"9071","h_team":"FC Krasnodar","a_team":"Ural"}]}

tableI的帮助下,以下每个unicode字符代表什么:

\x7B = {
\x22 = " 
\x3A = : 
\x5B = [  
\x7D = }
\x5D = ]

因此,我编写了以下脚本:

string = '\x7B\x22h\x22\x3A\....\\x22\x22\x7D\x5D\x7D'
cleaned_string = string.replace("\x7B","{")
cleaned_string = cleaned_string.replace('\x22', '"')
cleaned_string = cleaned_string.replace("\x3A", ":")
cleaned_string = cleaned_string.replace("\x5B", "[")
cleaned_string = cleaned_string.replace("\x7D", "}")
cleaned_string = cleaned_string.replace("\x5D", "]")
s = json.loads(cleaned_string)

然而,问题出现在玩家-玩家辅助领域。特别是,对于法语或西班牙语名称,可能有多个特殊字符。目前,我的脚本只是转换“标准”字符。从理论上讲,当然还有很多不同的角色需要改造。我怎样才能轻松地做到这一点

提前谢谢


Tags: idteamgoalsx22x22idx7bx7dx3a

热门问题