我有一个Excel文件,其中包含两列,第一个是中文,第二个是链接。 我尝试了两种我在这里找到的方法。但它不起作用,我无法在控制台中打印值,我将设置(pycharm)中的编码变量更改为U8,但仍然无效。 我用熊猫& xlrd libs,两者都没有工作,但它为其他人张贴。 这是我当前的代码:从excel文件读取汉字python3
from xlrd import open_workbook
class Arm(object):
def __init__(self, id, dsp_name):
self.id = id
self.dsp_name = dsp_name
def __str__(self):
return("Arm object:\n"
" Arm_id = {0}\n"
" DSPName = {1}\n"
.format(self.id, self.dsp_name))
if __name__ == '__main__':
wb = open_workbook('test.xls')
for sheet in wb.sheets():
print(sheet)
number_of_rows = sheet.nrows
number_of_columns = sheet.ncols
items = []
rows = []
for row in range(1, number_of_rows):
values = []
for col in range(number_of_columns):
value = str(sheet.cell(row, col).value)
for a in value:
print('\n'.join([a]))
values.append(value)
print(value)
for item in items:
print (item)
print("Accessing one single value (eg. DSPName): {0}".format(item.dsp_name))
print
显然它不工作,我只是用它放弃后瞎搞。 文件:http://www59.zippyshare.com/v/UxITFjis/file.html