我是靠谱客的博主 独特花瓣,这篇文章主要介绍利用python读取文件 然后以表格的形式打印出去,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##coding:utf-8 ''' Created on 2014-7-28 @author: Administrator ''' #coding:utf-8 def html_table(): html = ''' <table border = "1"> <tr> <th>ID</th> <th>name</th> <th>des</th> </tr>''' f=open("F:/pyfile/abc.txt","r+") ff = f.read() i=1 while i<4: html+=''' <tr> ''' # one = ff.find('(1)') # # oone = ff.find('(1)',ff.find('(1)')+1) ## ooone=ff.find('(1)',one+1) # two = ff.find('(2)') # three= ff.find('(3)') ##+表示去掉前面的(1)(2)(3) onetwo=ff[findSubStr('(1)',ff,i)+3:findSubStr('(2)',ff,i)] twothree=ff[findSubStr('(2)',ff,i)+3:findSubStr('(3)',ff,i)] threeone=ff[findSubStr('(3)',ff,i)+3:findSubStr('(1)',ff,i+1)] print onetwo print twothree print threeone i+=1 html += ''' <tr> <td>%s</td> <td>%s</td> <td>%s</td> </tr> ''' % (onetwo,twothree,threeone) html+=''' </tr> ''' html += ''' </table> ''' f1=open("F:/pyfile/fff.html","w+") f1.write(html) def findSubStr(substr, str, i): count = 0 while i > 0: index = str.find(substr) if index == -1: return -1 else: str = str[index+1:] #第一次出现该字符串后后面的字符 i -= 1 count = count + index + 1 #位置数总加起来 return count - 1 html_table()


读取文件的实例

001.SmartFrog
http://smartfrog.org/display/sf/SmartFrog+Home
SmartFrog是用于配置,部署和管理分布式软件系统的强大而灵活的基于Java的软件框架。
SmartFrog帮助你来封装和管理系统,使他们很容易配置和重新配置,并让他们可以自动安装,启动和关闭。它提供了业务流程的能力,使子系统可以启动(和停止)以正确的顺序。它还可以帮助您检测并从故障中恢复。

002.Ant
http://ant.apache.org/
Apache Ant是一个将软件编译、测试、部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发。

003.axis
http://axis.apache.org/
ApacheAxis是一个开源、建基于XML的Web服务架构。它包含了Java和C++语言实现的SOAP服务器,以及各种公用服务及API以生成和部署Web服务应用。

004.dom4j
http://www.dom4j.org/
DOM4J是一个易于使用的,用于XML,XPath和XSLT使用Java集合框架在Java平台上,并与DOM,SAX和JAXP全面支持工作的开源库。

005.maven
http://maven.apache.org/
Apache Maven是一个软件项目管理工具。基于项目对象模型(POM)的概念,Maven的可以管理项目的构建、报告和文档。

006.OpenMeetings
http://openmeetings.apache.org/
Openmeetings提供视频会议,即时通讯,白板,协同文档编辑和使用的Red5流媒体服务器的远程处理和流媒体API函数等群件工具。

007.tomcat
http://tomcat.apache.org/
Apache Tomcat是一个实现了Java Servlet和JavaServer Pages技术的开源软件。

008.fastjson
Fastjson是一个json处理工具包,包括“序列化”和“反序列化”两部分,它具备如下特征:
1.速度最快,测试表明,fastjson具有极快的性能,超越任其他的java json parser。包括自称最快的jackson。
2.功能强大,完全支持java bean、集合、Map、日期、Enum,支持范型,支持自省。
3.无依赖,能够直接运行在Java SE 5.0以上版本
4.支持Android。
5.开源 (Apache 2.0)

009.jexcel
http://jexcelapi.sourceforge.net/
Java Excel API(JXL)是一个成熟,开源的用来操作Excel电子表格的Java类库,支持读取,修改,写入等操作。这个项目基于GPL发布,而且对中文有很好的支持。

010.commons
http://commons.apache.org/
The Commons is an Apache project focused on all aspects of reusable Java components.
Apache的工具库

011.easymock
http://easymock.org/
Easy mocking. Better testing.

012.poi
http://poi.apache.org/
Apache POI - the Java API for Microsoft Documents

013.jython
http://www.jython.org/
Python for the Java Platform

014.tomcat
http://tomcat.apache.org/
Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.

015.struts2
http://struts.apache.org/development/2.x/
Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications.

016.spring
http://projects.spring.io/spring-framework/
The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.



017.maven
http://maven.apache.org/
Apache Maven is a software project management and comprehension tool.


最后

以上就是独特花瓣最近收集整理的关于利用python读取文件 然后以表格的形式打印出去的全部内容,更多相关利用python读取文件内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部