美文网首页
openpyxl基础知识

openpyxl基础知识

作者: 把日子过成年 | 来源:发表于2017-04-14 19:07 被阅读0次

#-*- coding: UTF-8 -*-

importsys

importtime

importurllib

importurllib2

importrequests

importnumpyasnp

frombs4importBeautifulSoup

fromopenpyxlimportWorkbook

reload(sys)

sys.setdefaultencoding('utf8')

#Some User Agents

hds=[{'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'},\

{'User-Agent':'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.12 Safari/535.11'},\

{'User-Agent':'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'}]

fromopenpyxlimportWorkbook

wb = Workbook()

# grab the active worksheet

ws = wb.active

# Data can be assigned directly to cells

ws['A1'] =42

# Rows can also be appended

ws.append([1,2,3])

# Python types will automatically be converted

importdatetime

ws['A2'] = datetime.datetime.now()

# Save the file

wb.save("sample.xlsx")

相关文章

网友评论

      本文标题:openpyxl基础知识

      本文链接:https://www.haomeiwen.com/subject/kjlgattx.html