Python将爬取的内容保存在EXCEL中报错:AttributeError: 'str' object has no attribute 'save'

问题遇到的现象和发生背景

想将爬取的内容保存在EXCEL中,但是在保存EXCEL文件的时候报错:AttributeError: 'str' object has no attribute 'save'。代码在下面。

问题相关代码,请勿粘贴截图
def getHtml():
    #k代表存储到Excel的行数
    k=1
    #创建一个工作簿
    f = xlwt.Workbook(encoding='utf-8')
    sheet = f.add_sheet("KMI变化",cell_overwrite_ok=True)
    mingcheng=['综合','服务','制造业']
    lieshi=[0,3,6]
    for i in range(3):
        sheet.write(0, lieshi[i], mingcheng[i])
    for h in range(20):
        sheet.write(h,0,x_data[h])
f.save('F:/KMI.xlsx')
getHtml()

运行结果及报错内容
Traceback (most recent call last):
  File "E:/PP/HHH.py", line 63, in <module>
    f.save('F:/KMI.xlsx')
AttributeError: 'str' object has no attribute 'save'

望指教

f要缩进,属于函数