如何在调用 google 分析 API 时删除 python 中的多余引号

How to remove extra quotes in python while calling google analytics API

第 1 步:读取文件

#read the csv file
with open('myfile.csv', 'rt') as csvfile:
    reader = csv.reader(csvfile, dialect='excel')
    reader_list = list(reader)
    for row in reader_list:
        print(row[0])
        print(type(row[0])) #printing the type just for illustration 


输出

'171667494.1541516384'
<class 'str'>
'548162985.1541558366'
<class 'str'>
'149398364.1541533183'
<class 'str'>
'888359874.1541543604'
<class 'str'>
'1628297960.1541566771'

第 2 步:我想将完全相同的字符串(带单引号)传递给 google API,如下所示。我该如何摆脱它?

for row in reader_list:
 user_deletion_request_resource.upsert(
            body = {
  "id": {  # User ID.
      "userId": row[0],  # I am passing the strings here 
      "type": "CLIENT_ID"
      }}
        ).execute()

出于某种原因,API 在 userId

中采用了如下所示的额外报价
{'id': {'type': 'CLIENT_ID', 'userId': "'785972698.1540375322'"}, 'deletionRequestTime': '2020-02-03T08:25:16.796Z'}

尝试

"userId": row[0].replace("'", "")

这应该用空格去掉刻度线。