码迷,mamicode.com
首页 > 编程语言 > 详细

python3 xlwt 配置文件读写Agent

时间:2018-07-02 23:02:40      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:tle   default   div   add   code   sel   sheet   for   tar   

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:\python\xlrdwtutils\test.xls"
myAgent = configAgent(testAgentFile)
myAgent.write_row((hello, world))
myAgent.write_to_file()
os.system("pause")

 

python3 xlwt 配置文件读写Agent

标签:tle   default   div   add   code   sel   sheet   for   tar   

原文地址:https://www.cnblogs.com/secoolar/p/9256069.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!