Compare lists in python while looping

前端 未结 1 848
长情又很酷
长情又很酷 2021-01-22 00:09

I have a script which I\'m using to read an excel file and update an SQL database. I\'m reading the excel file every 30 seconds using a loop. However I only want to update the d

相关标签:
1条回答
  • 2021-01-22 00:17

    Yes, Python built-in containers are compared by value (both tuples, lists and dicts).

    Something like this (I used a list comprehension to add fanciness):

    //init
    pvv=None
    
    <...>
    
    //iteration
    vv= [data.cell(i,j).value for (i,j) in ((2,26),(3,26),(4,26))]
    if vv!=pvv: 
        //do something
        pvv=vv
    
    0 讨论(0)
提交回复
热议问题