python3 xlwt 配置文件读写Agent
Posted secoolar
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3 xlwt 配置文件读写Agent相关的知识,希望对你有一定的参考价值。
import os import xlwt class configAgent: sequence = 0 targetFile = ‘‘ defautPolicy = None worksheet = None def __init__(self, targetFile): self.targetFile = targetFile self.defautPolicy = xlwt.Workbook(encoding = ‘ascii‘) self.worksheet = self.defautPolicy.add_sheet(‘defaultStrategy‘) def write_title(self, titles): i = 0 for title in titles: self.worksheet.write(0,i, label = title) i = i + 1 def write_row(self, words): i = 1 for word in words: self.worksheet.write(self.sequence, i, label = str(i * self.sequence)) i = i + 1 self.sequence = self.sequence + 1 def write_to_file(self): self.defautPolicy.save(self.targetFile) testAgentFile = r"K:pythonxlrdwtutils est.xls" myAgent = configAgent(testAgentFile) myAgent.write_row((‘hello‘, ‘world‘)) myAgent.write_to_file() os.system("pause")
以上是关于python3 xlwt 配置文件读写Agent的主要内容,如果未能解决你的问题,请参考以下文章