2 ответов
+ 3
There are many ways to compare lists of unicode-encoded strings in Python.
You can compare for equality like this:
mylist=[u'marc',u'max',u'chan',u'jackie']
mysecondlist=[u'marc',u'max', u'chan',u'jackie']
print(mylist == mysecondlist) # prints True indicating they're equal.
You could convert to sets if you want to see what elements are in one set and not in the other like this:
mylist=[u'marc',u'max',u'chan',u'jackie']
mysecondlist=[u'marc',u'china',u'france']
print(list(set(mylist) - set(mysecondlist))) # prints ['max', 'jackie', 'chan']. marc is in mysecondlist so it was not printed.
0
thank you Josh ! may be you could check my other question : https://www.sololearn.com/Discuss/2739041/comparing-excel-cell-values-with-JUMP_LINK__&&__python__&&__JUMP_LINK-openpyxl