如何使用python3从Excel文件中提取所有行并删除特殊字符?
Table.xlsx
import xlrd
loc = ("Table.xlsx")
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
sheet.cell_value(0, 0)
print(sheet.row_values(1))
Expected Output:
最佳答案
这在 Word 文档中对我有用。它可能对你有同样的作用...
我使用的函数:
import re
def removeSpecialCharacters(cellValue):
text=re.sub(r"[\r\n\t\x07\x0b]", "", cellValue)
return text
之后,我用它作为值:
character = table.Cell(Row = 1, Column = 1).Range.Text
character = removeSpecialCharacters(character)
您也可以使用 for 循环来解决您的解决方案。
关于python - 如何使用python3从excel(xlsx)文件中删除特殊字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55494593/