python - AttributeError: 'int' 对象没有属性 'split' excel 错误
问题描述
我收到以下错误:
AttributeError: 'int' object has no attribute 'split'
我编写了一个代码来添加一个新列,并在给定的文本列中在特定单词之前提到 2 个单词,在之后提到两个单词。
我使用 nlp 在 python 中尝试了一个代码。
import openpyxl
path5 = "C:\\Users\\AC48330\\Desktop\\my files\\FINAL.xlsx"
wb = openpyxl.load_workbook(path5)
Sheet = wb['Sheet']
y = 'you'
line = Sheet['AW']
for i, cellObj in enumerate(Sheet['AW'], 1):
for line in [i]:
split_line = line.split()
if y in split_line:
index = split_line.index(y)
print((' '.join(split_line[max(0, index - 2):min(index +
3,len(split_line))])), Sheet['BB'])
wb.save('finale.xlsx')
预期输出是 - 单词 word 关键字 word word - 在新列中
解决方案
推荐阅读
- 3d - Onirix Targets 播放器应用程序中的 3D 模型质量不佳
- r - 仅时间转换(小时和分钟)
- c# - 从 WebClient 清除结果
- javascript - 如何从另一个 js 文件/函数中触发 mongoose post hook?
- excel - 使用 Excel 和 VBA 从 PowerPoint 文件生成 PDF 文件
- html - 如何用输入字段和按钮并排填充一行?
- excel - 如何使用 sumifs 和 countifs 在 MS excel 中计算销售天数?
- r - 使用带有自定义步骤的食谱在烘焙时效果很好,但在使用插入符号训练模型时效果不佳
- iframe - Fancybox 3 - 全屏显示 iframe 库
- rest - 如何选择在 REST 中更新资源的方法