gspread在sheet2中复制一个范围并将该范围粘贴到sheet 1中

时间:2019-03-01 02:41:16

标签: gspread

我正在尝试在工作表2中复制一个范围并将该范围粘贴到工作表1。我的代码似乎能够进行复制,但不能进行粘贴。请帮忙。 感谢您抽出宝贵的时间来帮助您。

tickers_sheet = client.open('XBRL_Y_BS_Names').get_worksheet(2)
cik_ranges = ['C2:C150','F2:F150']

for x in cik_ranges:
    cik_list = tickers_sheet.range(x)
    for i in cik_list:
        print(i.value)
    call_sheet = client.open('XBRL_Y_BS_Names').get_worksheet(1)
# paste the results to range P22:P170 in call_sheet:
    call_sheet.update_cells('P22:P170',i)

错误似乎是最后一行:

Traceback (most recent call last):
  File "C:/PyCodes/Tickers.py", line 23, in <module>
    call_sheet.update_cells('P22:P170',i)
  File "C:\Users\BuiTi\AppData\Roaming\Python\Python37\site-packages\gspread\models.py", line 769, in update_cells
    values_rect = cell_list_to_rect(cell_list)
  File "C:\Users\BuiTi\AppData\Roaming\Python\Python37\site-packages\gspread\utils.py", line 233, in cell_list_to_rect
    row_offset = cell_list[0].row
AttributeError: 'str' object has no attribute 'row'

Process finished with exit code 1

0 个答案:

没有答案