字符串是使用静态的方式进行存储,只能读而不能直接修改字符内容。特别将一堆对字符串并在一起的时候,虽然可以直接相加,听说这样的速度奇慢,只有用其它函数的方式进行,好在也不太麻烦。
比如用 print ','.join(datelist)
就可以将datelist列表里面的所有项目并成一个字符串,当然这个表达式会在每一个项目中间插入一个逗号,这种方式比用循环的方式更简洁。
日期的操作必须使用time或datetime库
import time
>>> s="2006-1-2"
>>> time.strptime(s,"%Y-%m-%d)
这是将字符串格式的日期及时间转成日期对象
转义符对应意义如下
%a 本地简化星期名称
%A 本地完整星期名称
%b 本地简化的月份名称
%B 本地完整的月份名称
%c 本地相应的日期表示和时间表示
%d 月内中的一天(0-31)
%H 24小时制小时数(0-23)
%I 12小时制小时数(01-12)
%j 年内的一天(001-366)
%m 月份(01-12)
%M 分钟数(00=59)
%p 本地A.M.或P.M.的等价符
%S 秒(00-59)
%U 一年中的星期数(00-53)星期天为星期的开始
%w 星期(0-6),星期天为星期的开始
%W 一年中的星期数(00-53)星期一为星期的开始
%x 本地相应的日期表示
%X 本地相应的时间表示
%y 两位数的年份表示(00-99)
%Y 四位数的年份表示(000-9999)
%Z 当前时区的名称
%% %号本身
============================================
#-*- coding:utf-8 -*-
import time
import datetime
# 2007-11-25 15:36:35
#使用datetime模块可以很方便的解决这个问题,举例如下:
d1 = datetime.datetime(2005, 2, 16)
d2 = datetime.datetime(2004, 12, 31)
# 结果:47
print (d1 - d2).days
#上例演示了计算两个日期相差天数的计算。
starttime = datetime.datetime.now()
endtime = datetime.datetime.now()
print (endtime - starttime).seconds
#上例演示了计算运行时间的例子,以秒进行显示。
d1 = datetime.datetime.now()
d3 = d1 + datetime.timedelta(days =10)
print str(d3)
print d3.ctime()
# 上例演示了计算当前时间向后10天的时间。
# 如果是小时 days 换成 hours
# 其本上常用的类有:datetime和timedelta两个。它们之间可以相互加减。
# 每个类都有一些方法和属性可以查看具体的值,如datetime可以查看:天数(day),小时数(hour),星期几(weekday())等;
# timedelta可以查看:天数(days),秒数(seconds) 等。
#
# time , datetime , string 类型互相转换
#
# string -> time
# time.strptime(publishDate,"%Y-%m-%d %H:%M:%S")
#
# time -> string
# time.strftime("%y-%m-%d",t)
date = '2007-01-01'
print type(date)
date = time.strptime(date,"%Y-%m-%d")
print type(date)
print date[0]
d4 = datetime.datetime(date[0], date[1],date[2])
print d4
print type(d4)
#将日期时间对象转成字符串则要用
date = time.strftime("%y-%m-%d",date)
print type(date)
#其中d为日期时间对象
2008/03/25
latex中如何添加附录,术语,符号
1. latex中怎样加附录
在开头加入
\usepackage[page,title,titletoc,header]{appendix}
在末尾加入
%%%%%%%%% Appendices
\begin{appendices}
\input{appa}
\input{appb}
\end{appendices}
%\appendix
%\include{appa} % doc for gps+cell scheme
%\include{appb} % tables for GPS
2. add glossary 创建术语表
\usepackage{glossary}
\makeglossary
\storeglosentry{pdf}{name=pdf, description=probability density function}
%%% storeglosentry必须放在引用的前面
\begin{document}
... \gls{pdf} is named ...
\printglossary
\addcontentsline{toc}{chapter}{Glossary}
\end{document}
完整的编译过程 How to generate PDF:
* use latex to generate PDF once. An *.ist file as well as a glossary file (*.glo) are generated. The glossary-file contains all the glossary entries found in the document in plain text.
* Next you type the following command in the command-line:
makeindex -s mydoc.ist -t mydoc.glg -o mydoc.gls mydoc.glo
generating the two files with the extensions *.gls and *.glg.
* You now need to re-generate the PDF, using latex.
3. add notations 创建符号表
\usepackage{nomencl}
\makenomenclature
...
...
\nomenclature{$\mathbb{R}^2$}{two-dimensional space}
\addcontentsline{toc}{chapter}{List of Notations}
\printnomenclature
完整编译过程为:
* latex
* makeindex mydoc.nlo -s nomencl.ist -o mydoc.nls
* latex
源文件在第一次编译后,自动生成一个同名术语条目文件.nlo,运行 makeindex 工具程序和术语样式文件 nomencl.ist 对其编译,再生成一个同名术语排序文件.nls,当再次编译源文件时,\printnomenclature 命令将被这个文件的内容所取代。
refer to:
http://texblog.wordpress.com/2007/11/01/glossary-in-latex/
http://zzg34b.w3.c361.com/package/note-2.htm
在开头加入
\usepackage[page,title,titletoc,header]{appendix}
在末尾加入
%%%%%%%%% Appendices
\begin{appendices}
\input{appa}
\input{appb}
\end{appendices}
%\appendix
%\include{appa} % doc for gps+cell scheme
%\include{appb} % tables for GPS
2. add glossary 创建术语表
\usepackage{glossary}
\makeglossary
\storeglosentry{pdf}{name=pdf, description=probability density function}
%%% storeglosentry必须放在引用的前面
\begin{document}
... \gls{pdf} is named ...
\printglossary
\addcontentsline{toc}{chapter}{Glossary}
\end{document}
完整的编译过程 How to generate PDF:
* use latex to generate PDF once. An *.ist file as well as a glossary file (*.glo) are generated. The glossary-file contains all the glossary entries found in the document in plain text.
* Next you type the following command in the command-line:
makeindex -s mydoc.ist -t mydoc.glg -o mydoc.gls mydoc.glo
generating the two files with the extensions *.gls and *.glg.
* You now need to re-generate the PDF, using latex.
3. add notations 创建符号表
\usepackage{nomencl}
\makenomenclature
...
...
\nomenclature{$\mathbb{R}^2$}{two-dimensional space}
\addcontentsline{toc}{chapter}{List of Notations}
\printnomenclature
完整编译过程为:
* latex
* makeindex mydoc.nlo -s nomencl.ist -o mydoc.nls
* latex
源文件在第一次编译后,自动生成一个同名术语条目文件.nlo,运行 makeindex 工具程序和术语样式文件 nomencl.ist 对其编译,再生成一个同名术语排序文件.nls,当再次编译源文件时,\printnomenclature 命令将被这个文件的内容所取代。
refer to:
http://texblog.wordpress.com/2007/11/01/glossary-in-latex/
http://zzg34b.w3.c361.com/package/note-2.htm
2008/03/24
latex中的表格
\begin{table}[h]
\small % change the font size
\begin{tabular*}{1.0\textwidth}{ lll }
%\begin{tabular} {lll}
%\begin{tabular*}{0.75\textwidth}{ @{\extracolsep{\fill}} lll}
\hline
Name & Example Data & Description \\
\hline
Sentence Identifier & \$GPGGA & GPS Fix Data \\
Time & 031145.999 & 03:11:45.999 UTC \\
Latitude & 0120.3055, N & 1 degree 20.3055 minutes North \\
Longitude & 10346.6611, E & 103 degree 46.6611 minutes East \\
Fix Quality &1& Data is from a GPS fix \\
Number of Satellites &05& 5 Satellites are in view \\
Horizontal Dilution of Precision &00.0& Relative accuracy of horizontal position \\
Altitude &163.3, M& 163.3 meters above mean sea level \\
Height above WGS84 ellipsoid & 156.2, M& 156.2 meters \\
Time since last DGPS update &blank& No last update \\
DGPS reference station id &blank& No station id \\
Checksum &*6F& Checksum for transmission errors \\
\hline
\end{tabular*}
\end{table}
\small % change the font size
\begin{tabular*}{1.0\textwidth}{ lll }
%\begin{tabular} {lll}
%\begin{tabular*}{0.75\textwidth}{ @{\extracolsep{\fill}} lll}
\hline
Name & Example Data & Description \\
\hline
Sentence Identifier & \$GPGGA & GPS Fix Data \\
Time & 031145.999 & 03:11:45.999 UTC \\
Latitude & 0120.3055, N & 1 degree 20.3055 minutes North \\
Longitude & 10346.6611, E & 103 degree 46.6611 minutes East \\
Fix Quality &1& Data is from a GPS fix \\
Number of Satellites &05& 5 Satellites are in view \\
Horizontal Dilution of Precision &00.0& Relative accuracy of horizontal position \\
Altitude &163.3, M& 163.3 meters above mean sea level \\
Height above WGS84 ellipsoid & 156.2, M& 156.2 meters \\
Time since last DGPS update &blank& No last update \\
DGPS reference station id &blank& No station id \\
Checksum &*6F& Checksum for transmission errors \\
\hline
\end{tabular*}
\end{table}
2008/03/22
latex 文献(bib)管理软件
Kbibtex (首选)
Ubuntu下bib 文件管理。在kile -> settings -> Tools->build中 view bib file by kbibtex.
安装 Applications->add/remove 或者 sudo apt-get install kbibtex
JabRef
一个用java写的文献管理器。可在ubuntu menu: Applications->add/remove下直接安装,但是restricted software (not open source)。或下载从
http://jabref.sourceforge.net/index.php
Referencer
一个GNOME 应用程序,它支持最终生成 BibTeX 格式的文献文件。 主要功能包括:
* 可自动检索元数据
* 智能化的 Web 链接处理方式
* 支持从 BibTeX、Reference Manager、EndNote 等软件导入文献文件
* 支持 Tagging
Referencer 的最新版本为 1.0.2,有源码包和 deb 包可用。
Bibus
BiBus基于Python,Windows和Linux版本都有,Ubuntu下安装Bibus只要敲 sudo apt-get install bibus,就OK(JabRef同理)。
第一次使用前要选择数据库,MySQL或SQLite任选其一。
Note:
windows下有EndNote, Biblioscape, NoteExpress,Reference Manager,ProCite.
在线版或者以浏览器插件形式存在的有EndNote Web和Zotero.
Ubuntu下bib 文件管理。在kile -> settings -> Tools->build中 view bib file by kbibtex.
安装 Applications->add/remove 或者 sudo apt-get install kbibtex
JabRef
一个用java写的文献管理器。可在ubuntu menu: Applications->add/remove下直接安装,但是restricted software (not open source)。或下载从
http://jabref.sourceforge.net/index.php
Referencer
一个GNOME 应用程序,它支持最终生成 BibTeX 格式的文献文件。 主要功能包括:
* 可自动检索元数据
* 智能化的 Web 链接处理方式
* 支持从 BibTeX、Reference Manager、EndNote 等软件导入文献文件
* 支持 Tagging
Referencer 的最新版本为 1.0.2,有源码包和 deb 包可用。
Bibus
BiBus基于Python,Windows和Linux版本都有,Ubuntu下安装Bibus只要敲 sudo apt-get install bibus,就OK(JabRef同理)。
第一次使用前要选择数据库,MySQL或SQLite任选其一。
Note:
windows下有EndNote, Biblioscape, NoteExpress,Reference Manager,ProCite.
在线版或者以浏览器插件形式存在的有EndNote Web和Zotero.
2008/03/21
latex文件头定义冲突
在latex中使用ACM proceedings格式文件(acm_proc_article-sp.cls)时,如果用到了algorithm2e的包,编译时会出现:
! Too many }'s.
该冲突可直接在文件开头加入下面5句话解决:
\makeatletter
\newif\if@restonecol
\makeatother
\let\algorithm\relax
\let\endalgorithm\relax
! Too many }'s.
该冲突可直接在文件开头加入下面5句话解决:
\makeatletter
\newif\if@restonecol
\makeatother
\let\algorithm\relax
\let\endalgorithm\relax
订阅:
博文 (Atom)