Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pygsheet中的GSheet包装策略_Python_Google Sheets_Google Sheets Api_Pygsheets - Fatal编程技术网

Python pygsheet中的GSheet包装策略

Python pygsheet中的GSheet包装策略,python,google-sheets,google-sheets-api,pygsheets,Python,Google Sheets,Google Sheets Api,Pygsheets,在Pygsheet引用文档中,它显示一个wrap_策略属性 wrap_strategy How to wrap text in this cell. Possible wrap strategies: ‘OVERFLOW_CELL’, ‘LEGACY_WRAP’, ‘CLIP’, ‘WRAP’. Reference: api docs 但在实际代码中,如果我要cell.wrap\u策略='wrap'我会得到一个错误TypeError:'str'对象不可调用 实际代码段: for cell in

在Pygsheet引用文档中,它显示一个wrap_策略属性

wrap_strategy
How to wrap text in this cell. Possible wrap strategies: ‘OVERFLOW_CELL’, ‘LEGACY_WRAP’, ‘CLIP’, ‘WRAP’. Reference: api docs
但在实际代码中,如果我要
cell.wrap\u策略='wrap'
我会得到一个错误
TypeError:'str'对象不可调用

实际代码段:

for cell in wsheet.range("L3:L20").pop():
    cell.wrap_strategy('WRAP')

我相信你的目标如下

  • 您希望使用pygsheets设置包装策略
修改点:
  • 当我看到时,似乎这是类Cell,在本例中,我认为在wsheet.range(“L3:L20”).pop()中的单元格的
    ,您可以使用
    Cell.wrap\u策略='wrap'
    。(在这种情况下,设置为“L20”。)
从这里开始,按如下方式修改脚本如何

for cell in wsheet.get_values("L3", "L20", returnas="range")._data.pop():
    cell.wrap_strategy = "WRAP"
修改脚本: 或者,作为另一个方向,使用下面的
get_值如何

for cell in wsheet.get_values("L3", "L20", returnas="range")._data.pop():
    cell.wrap_strategy = "WRAP"
注:
  • 如果上述修改不是您问题的直接解决方案,您能否在不提供个人信息的情况下提供整个脚本?通过这一点,我想确认一下
参考:
补充: 从你下面的答复中,


我希望它能从L3到L20。但在这个for循环中似乎只有L20被读取。你知道怎么做吗

当我在你的问题中看到你的脚本时,你想使用
wsheet.range(“L3:L20”)
的最后一个元素,因为
pop()
。所以我就这么做了。从您的回复来看,当您想通过修改脚本来设置“L3:L20”的wap策略时,下面的示例脚本如何

样本1: 样本2:
我希望它能从L3到L20。但在这个for循环中似乎只有L20被读取。“你知道怎么做吗?”路易吉·麦肯齐C.布里托感谢你的回答。给您带来不便,我深表歉意。关于你的答复,我又加了一个样品。你能确认一下吗?如果这不是你所期望的方向,我道歉。没必要道歉。你太棒了,我现在明白了。我忘了为什么我会弹出它,但我打算在所有基于range@LuigiMackenzie C.Brito感谢您的回复和再次测试。我很高兴你的问题解决了。也谢谢你。
for cell in wsheet.range("L3:L20"):
    cell[0].wrap_strategy = "WRAP"
for cell in wsheet.get_values("L3", "L20", returnas="range")._data:
    cell[0].wrap_strategy = "WRAP"