Python从工作表的第一行搜索数字

问题描述 投票:0回答:1

我有一个连接到我的python代码的Google工作表我想让python只在第一行搜索数字例如,如果输入为“ 3”,则从第一行中找到3,然后输入日期或其他内容这是我的代码:

import gspread
from oauth2client.service_account import ServiceAccountCredentials
import datetime

scope = ['https://www.googleapis.com/auth/spreadsheets', "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json.json',scope)
a = raw_input("Type your Number")

client = gspread.authorize(credentials)
date = datetime.datetime.now()
sheet = client.open('hi').sheet1
if raw_input == '1':
    sheet.update_acell('B2', 'This Value for B2')
else: 
    print('r')
#print(sheet.get_all_records())
#sheet.append_row([str(date), 'this goes'])
python google-sheets datatable gspread
1个回答
0
投票

让我们将第一行的值存储在列表中并遍历它以找到匹配项,并获取列号以更新该列。

© www.soinside.com 2019 - 2024. All rights reserved.