当A栏填满时,我想移至B。我可以输入A或B,但是如果其中一个失败,则无法在两者之间切换。
编辑:我确定在没有尝试/例外的情况下代码可以工作。
def next_available_row(wks):
try:
str_list2 = list(filter(None, wks.col_values(1, 2)))
return str(len(str_list2)+1)
except:
str_list2 = list(filter(None, wks.col_values(2, 1)))
return str(len(str_list2)+1)
## try:
## wks.update_acell("A{}".format(next_row), tInput3)
## except:
wks.update_acell("B{}".format(next_row), tInput3)
因此,如果我屏蔽A列,则B列将正确填充。是什么赋予了? :|
答案 0 :(得分:0)
知道了。丑陋但可行。
def next_available_row(wks):
try:
str_list2 = list(filter(None, wks.col_values(1, 2)))
return str(len(str_list2)+1)
except:
print("unable to do 'A'")
def next_available_rowB(wks):
try:
str_list2 = list(filter(None, wks.col_values(2, 1)))
return str(len(str_list2)+1)
except:
print("unable to do 'B'")
try:
wks.update_acell("A{}".format(next_row), tInput3)
except:
wks.update_acell("B{}".format(next_rowB), tInput3)