Python 3在句子之间添加引号

时间:2019-04-13 22:02:43

标签: python file text text-files

我有一个名为datahead.txt的文件。它包含以下内容:

X-User-Id: Facebook_2110423665710376
X-Raw-User-Id: 53909fac-f2eb-4035-a000-50c58d22634e
X-User-Name: NN
X-Invite-Code: F9fHBuW6LQ
X-User-Token: AbzEbIQhA6X8-88v
X-Own-Mac: 02% 3A00% 3A00% 3A00% 3A00% 3A00
X-Resolution: 720 * 1280
X-Installer-App: com.android.vending
X-Operator-Desc: INDOSATOOREDOO +% 2851001% 29
X-Update-Codes: 0
X-Channel: Google Play
X-Is-Rooted: false
X-Google-AD-Status: false
X-Dpi: 320
X-Init-Channel: GooglePlay
X-Os-Version: 7.0
X-TimeZone: WIB
X-Net-Type: 4G
X-App-Name: Read + Plus
X-Os-Fire: 24
X-Location: 105.1205963% 2C-4,6255564
X-Google-AD-ID: beb8304b-959b-4434-8810-4aff77af11f1
X-APP-VERSION: 30430
X-Android-Id: c5e928804dd9a43
X-Device-Type: ADVAN ++ 5061
X-Device-Platform: android
X-Web-User-Agent: Mozilla% 2F5.0 +% 28Linux% 3B + Android + 7.0% 3B + 5061 + Build% 2FNRD90M% 3B + wv% 29 + AppleWebKit% 2F537.36 +% 28KHTML% 2C + like + Gecko% 29 + Version% 2F4.0 + Chrome% 2F59.0.3071.125 + Mobile + Safari% 2F537.36
Host: baca.co.id
Connection: Keep-Alive
User-Agent: Mozilla / 5.0 (Linux; Android 7.0; 5061 Build / NRD90M; wv) AppleWebKit / 537.36 (KHTML, like Gecko) Version / 4.0 Chrome / 59.0.3071.125 Mobile Safari / 537.36
Accept: text / html, application / xhtml + xml, application / json; q = 0.9, application / xml; q = 0.9, image / webp, * / *; q = 0.8
Accept-Encoding: gzip, deflate

我想将datahead.txt更新为以下内容:

'X-User-Id': 'Facebook_2110423665710376',
'X-Raw-User-Id': '53909fac-f2eb-4035-a000-50c58d22634e',
'X-User-Name': 'NN',
'X-Invite-Code': 'F9fHBuW6LQ',
'X-User-Token': 'AbzEbIQhA6X8-88v',
'X-Own-Mac': '02% 3A00% 3A00% 3A00% 3A00% 3A00 ',
'X-Resolution': '720 * 1280', 'X-Installer-App': 'com.android.vending',
'X-Operator-Desc': 'INDOSATOOREDOO +% 2851001% 29',
'X-Update-Version-code': '0',
'X-Channel': 'Google Play',
'X-Is-Rooted': 'false',
'X-Google-AD-Status': 'false',
'X-Dpi': '320',
'X-Init-Channel': 'Google Play',
'X-Os-Version': '7.0',
'X-TimeZone': 'WIB',
'X-Net-Type': '4G',
'X-App-Name': 'Read + Plus',
'X-Os-Fire': '24',
'X-Location': '105.1205963% 2C-4,6255564',
'X-Google-AD-ID': 'beb8304b-959b-4434-8810-4aff77af11f1',
'X-APP-VERSION': '30430',
'X-Android-Id': 'c5e928804dd9a43',
'X-Device-Type': 'ADVAN ++ 5061',
'X-Device-Platform': 'android',
'X-Web-User-Agent': 'Mozilla% 2F5.0 +% 28Linux% 3B + Android + 7.0% 3B + 5061 + Build% 2FNRD90M% 3B + wv% 29 + AppleWebKit% 2F537.36 +% 28KHTML% 2C + like + Gecko% 29 + Version% 2F4.0 + Chrome% 2F59.0.3071.125 + Mobile + Safari% 2F537.36 ',
'Host': 'baca.co.id',
'Connection': 'Keep-Alive',
'User-Agent': 'Mozilla / 5.0 (Linux; Android 7.0; 5061 Build / NRD90M; wv) AppleWebKit / 537.36 (KHTML, like Gecko) Version / 4.0 Chrome / 59.0.3071.125 Mobile Safari / 537.36',
'Accept': 'text / html, application / xhtml + xml, application / json; q = 0.9, application / xml; q = 0.9, image / webp, * / *; q = 0.8',
'Accept-Encoding': 'gzip, deflate'

我该怎么做?

1 个答案:

答案 0 :(得分:-1)

也许,您可以尝试:

id in ( SELECT geo_id FROM users)

python code