添加了“ abcd - > defg-> ghij&quot由Apped_row

发布于 2025-02-14 02:20:48 字数 718 浏览 3 评论 0 原文

import gspread
import random

gc = gspread.service_account(filename='영업인만들기\gspread-******-**********.json')

sh = gc.open("관리자_종합_DB") 
worksheet = sh.worksheet("영업인") 


Name = input('영업인 이름 : ')
Email = input('영업인 이메일 : ')


alist = worksheet.col_values(4)[1:] 

a = random.randint(10000,99999)       
while a in alist :              
    a = random.randint(10000,99999)

worksheet.append_row([Name,Email,'',a])

如果我写下姓名和电子邮件,则会出现一个随机代码。

但是,当我运行它时,它写在Google表上。


这是运行3次的结果。

在此处输入图像描述

它不是以“ abcd - > abcd; abcd·Abcd”的形式编写“它以“ ABCD”形式写成 - >

我该如何解决?

import gspread
import random

gc = gspread.service_account(filename='영업인만들기\gspread-******-**********.json')

sh = gc.open("관리자_종합_DB") 
worksheet = sh.worksheet("영업인") 


Name = input('영업인 이름 : ')
Email = input('영업인 이메일 : ')


alist = worksheet.col_values(4)[1:] 

a = random.randint(10000,99999)       
while a in alist :              
    a = random.randint(10000,99999)

worksheet.append_row([Name,Email,'',a])

If I write down name and email, a random code will come out.

But when I run it, it's written strangely on the Google sheet.


This is the result of running it 3 times.

enter image description here

It's not written in the form "ABCD -> ABCD ··· ABCD", it's written in the form "ABCD -> DEFG -> GHIJ".

How do I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪菊怪哟 2025-02-21 02:20:48

问题 append_row 试图找到逻辑表附加到。而且,当您在上一行中有空单元格时,它可以将此逻辑表向右移动。 被引入以指定您要在哪里开始附加数据。这避免了 append_row 尝试自己找到逻辑表。

worksheet.append_row([Name,Email,'',a], table_range='A1')

The issue is that append_row tries to find a logical table to append to. And when you have empty cells in your previous row it could move this logical table to the right. The parameter table_range was introduced to specify where you want to start appending the data from. This avoids append_row trying to find the logical table on its own.

worksheet.append_row([Name,Email,'',a], table_range='A1')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文