Это напечатает результаты первых листов, но оно не будет проходить за первой страницей.
Вывод для первой страницы точный и точный, он просто не пройдет мимо этого, и я не знаю почему. Я новичок, так что извините, если это очевидно, но я прочитал документы и не могу найти ответ. Спасибо.
import gspread
from oauth2client.service_account import ServiceAccountCredentials
sheets_of_months= ['May 2018 Chem Readings', 'April 2018 Chem Readings', 'June 2018 Chem Readings']
scope= ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds= ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client= gspread.authorize(creds)
def get_customers():
for name_of_sheet in sheets_of_months:
spread_sheet= client.open(name_of_sheet)
work_sheet= spread_sheet.sheet1
result= work_sheet.row_count
print result, name_of_sheet
get_customers()
Я понял, что проблема в этой строке
work_sheet= spread_sheet.sheet1
по какой-либо причине это останавливает его.
Edit:
def get_customers():
for name_of_sheet in sheets_of_months:
spread_sheet= client.open(name_of_sheet)
print name_of_sheet
work_sheet= spread_sheet.sheet1
print name_of_sheet
Вывод для этого сумасшедший.
May 2018 Chem Readings
April 2018 Chem Readings
June 2018 Chem Readings
June 2018 Chem Readings
Он проходит один раз до первого отпечатка, затем перебирает строку work_sheet = spread_sheet.sheet1, после чего начинается снова и печатается только один раз. Странно ....