为什么此if语句不能在for循环内执行?

时间:2020-09-22 23:24:30

标签: python list for-loop if-statement gspread

mgq_list = [] 
**# creating a list to place in values from a text file**
for lines_mgq in mgq_values: **# mgq_values is a text file by readlines**
    mgq_list.append(lines_mgq) 

int_col = 1 

for line in contents_text_file: #contents_text_file is populated with lines of notes
                    time.sleep(3)
                    str_col = str(int_col) # taking the int_col turning into a string
                    column_range = 'A' + str_col #creating a column range with the str_col counter
                    tab.update(column_range, line) #updating specific google sheet by column range
                    value_for_match = tab.acell(column_range).value #value_of_match gets current value
                
                    for line_mgq in mgq_list: # for value in list
                        if line_mgq in value_for_match: # if value of list is the in current column** 
                             tab.format(column_range, { # update background color to green if valid
                                "backgroundColor":{
                                    "green":1.0, 
                                }
                            })
                    int_col += 1 # increment column range

所以我想做的是从Google表格中获取一个值(str),并通过项目列表(str)运行它。如果该值对列表项之一有效,则当前列的背景应更改为绿色。

我能够打印出实际值,并且该列表实际上包含Google表格标签中的一些值。不知道从这里去哪里。

建议我以json格式尝试,但我不想回溯。

0 个答案:

没有答案