python - 请求来自带有转义字符的cookiejar问题的dict

python - 请求来自带有转义字符的cookiejar问题的dict,第1张

我遇到了一些使用python将cookie导入字典的问题。即使在运行请求提供的命令之后,它似乎也以某种方式被转义。

{'P-fa9d887b1fe1a997d543493080644610': '"\050dp1\012S\'variant\'\012p2\012S\'corrected\'\012p3\012sS\'pid\'\012p4\012VNTA2NjU0OTU4MDc5MTgwOA\075\075\012p5\012sS\'format\'\012p6\012S\'m3u8\'\012p7\012sS\'mode\'\012p8\012Vlive\012p9\012sS\'type\'\012p10\012S\'video/mp2t\'\012p11\012s."'}

这就是饼干的样子

{'format': 'm3u8', 'variant': 'corrected', 'mode': u'live', 'pid': u'NTA2NjU0OTU4MDc5MTgwOA==', 'type': 'video/mp2t'}

有没有办法让P-fa9d887b1fe1a997d543493080644610的值部分中未转义的字符转义为dict本身的一部分?

编辑:

我希望字典看起来像:

[ISSI]
;SplashScreen
; Name of the bitmap image:
#define ISSI_SplashScreen "C:\Users\Archangel_7\Downloads\Newfolder\AA_7.bmp "
; Time in seconds:
#define ISSI_SplashScreen_T 1
; Image Width:
#define ISSI_SplashScreen_X 488
; Image Heigth:
#define ISSI_SplashScreen_Y 199
; Include ISSI (required)
#define ISSI_IncludePath "C:\ISSI"
#include ISSI_IncludePath "\_issi.isi"
;WizardSmallBitmapImage [Default = [55x55]
#define ISSI_WizardSmallBitmapImage"C:\Users\Archangel_7\D ownloads\ensemble.bmp"
#define ISSI_WizardSmallBitmapImage_x 70
;WizardBitmapImage [Front & Back] [Default = 164x314]
#define ISSI_WizardBitmapImage"C:\Users\Archangel_7\Downlo ads\AOE.bmp"
#define ISSI_WizardBitmapImage_x 180
;define ISSI_WizardBitmapImage_Align
#define ISSI_WizardBitmapImage2 "C:\Users\Archangel_7\Downloads\AOE.bmp"
#define ISSI_WizardBitmapImage2_x 180
;define ISSI_WizardBitmapImage2_Align
;[Background Image]
;define ISSI_Image "C:\Users\Archangel_7\Downloads\AA7.bmp"

[Setup]
.....

[Languages]
.....

[Tasks]
....

[Files]
Source: C:\Users\Archangel_7\Desktop\Age of Empires\Redistributable\Directx\Dplay50a.exe; DestDir: {app}\Redistributable\Directx
Source: C:\Users\Archangel_7\Desktop\Age of Empires\Redistributable\Directx\Dxsetup.exe; DestDir: {app}\Redistributable\Directx

[Icons]
....

[Registry]
....

[Dirs]
....

[Run]
Filename: {app}\Redistributable\Directx\Dxsetup.exe; Description: Direct X; Flags: postinstall
Filename: {app}\Redistributable\Directx\Dplay50a.exe; Description: Direct Play v5.0a; Flags: postinstall

#define ISSI_UseMyCurPageChanged
[Code]
procedure ISSI_CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpFinished then
begin
WizardForm.RunList.Left:=198
end;
end;
#define ISSI_IncludePath "C:\ISSI"
#include ISSI_IncludePath "\_issi.isi" 

最佳答案:

1 个答案:

答案 0 :(得分:3)

您正在处理数据序列化的Python Pickle格式。一旦评估了表达式,所以转义的字符未转义,您需要使用pickle.loads函数从字符串加载pickle。

>>> import pickle
>>> import ast
>>> pickle.loads(ast.literal_eval("'''"   cookies.values()[0]   "'''")[1:-1])
{'pid': u'NTA2NjU0OTU4MDc5MTgwOA==', 'type': 'video/mp2t', 'variant': 'corrected', 'mode': u'live', 'format': 'm3u8'}
本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复