档案日期2014的41

2014年10月13日 - 2014年10月19日

使用Python xlwt写excel文件

如果需要使用Python写Excel文件,首先下载或者安装xlwt。

pip install xlwt

下面的这些demo应该可以帮助开发者快速上手使用xlwt写Excel文件:

创建工作簿(workbook)和工作表(sheet):

import xlwt
workbook = xlwt.Workbook() 
sheet = workbook.add_sheet("Sheet Name") 

写单元格(cell):

sheet.write(0, 0, 'foobar') # row, column, value

对单元格应用样式(加粗为例):

style = xlwt.easyxf('font: bold 1')
sheet.write ...

继续阅读

[Leetcode]Max Points on a Line

题目描述

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

题目大意

平面上有n个点,找出共线的点的最大个数

解题思路

很容易想到O(n^3)的解法,通过起点i,终点j枚举直线,然后枚举中间点k,依次判断k与i,j是否共线,统计最大值。

实际上,采用此题可以采用O(n^2 * log ...

继续阅读

[Leetcode]Evaluate Reverse Polish Notation

题目描述

Evaluate the value of an arithmetic expression in Reverse Polish Notation.

Valid operators are +, -, *, /. Each operand may be an integer or another expression.

Some examples:
  ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 ...

继续阅读

[Leetcode]Reverse Words in a String

题目描述

Given an input string, reverse the string word by word.

For example,
Given s = "the sky is blue",
return "blue is sky the".

Clarification:

What constitutes a word?
A sequence of non-space characters constitutes a word.

Could the input ...

继续阅读

每日归档

上周

下周

归档