Python 从Excel电子表格中提取值

Python 从Excel电子表格中提取值,python,python-3.x,xlrd,Python,Python 3.x,Xlrd,我想从单词列表中删除一些单词。我有一个反复出现的单词列表,我想把它去掉,但我不知道。我不知道是需要使用整个循环还是正则表达式 from xlrd import open_workbook,error_text_from_code book = open_workbook(inp) sheet0 = book.sheet_by_index(0) x = 0 y = 0 countr = sheet0.nrows countc = sheet0.ncols names = '' variabl

我想从单词列表中删除一些单词。我有一个反复出现的单词列表,我想把它去掉,但我不知道。我不知道是需要使用整个循环还是正则表达式

from xlrd import open_workbook,error_text_from_code

book = open_workbook(inp)

sheet0 = book.sheet_by_index(0)

x = 0
y = 0
countr = sheet0.nrows
countc = sheet0.ncols
names = ''
variables = []
"different variables-----------------"
while x < countr -1:
     x = x+1
     y = y+1
     cell = sheet0.cell(y,0)

names = names+ str(cell)
cell = sheet0.cell(y,1)

variables.append(cell)

country_text = names
countries = ', '.join(re.findall("('.*?')", country_text))
countries = countries.split()

print (variables)
print (countries)
我需要

[150000, 140000, 300000] 

如果使用循环,则可以使用以下函数访问单元格的值:

sheet0.cell_value(curr_row, curr_cell)

您是如何从第一个字符串中获得“青蛙”、“猪”、“狗”、“日志”的?他们似乎没有任何关系。这似乎非常不合理,因为他们没有得到青蛙的线索。我需要与我的第一根青蛙串相同的布局。那么你想要
“美国”、“英国”、“荷兰”
?你为什么一开始不这么说?如果我问自己“他面临的真正问题是什么?”,我认为是你在使用
xlrd
,并且使用
单元格
对象,而不是字符串和数字。如果是这样,可能会有用。
sheet0.cell_value(curr_row, curr_cell)