`
ericFang
  • 浏览: 99884 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

python

阅读更多

import os
filenames=os.listdir(os.getcwd())
num=raw_input('請輸入一個數字:')
for name in filenames:
 filenames[filenames.index(name)]=name[:-int(num)]
out=open('names.txt','w')
for name in filenames:
 out.write(name+'\n')
out.close()

 

 

try:
 filename=raw_input("eric")
 fobj=open(filename,'r')
 for eachLine in fobj:
  print eachLine,
 fobj.close()
except IOError e:

0
0
分享到:
评论
1 楼 ericFang 2011-04-18  
def getItemStandard(versionNumber,itemId):
    """
    versionNumber 版本号是excel中工作表的名称,如:ENIP_SUSE_V100R003C03
    itemId 巡检项对应的文件名,如:Item00_01_02
    得到对itemId的巡检标准
    """
    itemId = itemId.strip()
    itemStandard = None
    app = win32com.client.Dispatch('Excel.Application')
#    app.Visible = 1#不显示excel
    book = app.Workbooks.Open("E:\\ENIP_SUSE_V100R003C03.xls")
    sheet = book.Worksheets(versionNumber)#得到相应的工作表  
    sheetColumns = sheet.UsedRange.Columns(1)#得到工作表的第一列的实例
    totalRowCount = sheetColumns.Rows.Count#得到总的行数
    sheetCells = sheetColumns.Cells#得到一列的所有单元格对象
    #循环找到对应itemId的标准
#   print totalRowCount
    i = 1 
    while i < totalRowCount:
        tmpCell = sheetCells[i] #得到单元格对象
        tempItemId = str(tmpCell.Value)#得到单元格内容
#       print tempItemId + "  row:"+str(rowValue)+"  col:"+str(3)+" i="+str(i)
        if itemId == tempItemId:
            rowValue = tmpCell.Row #得到单元格行数
            colValue = tmpCell.Column + 2 #得到单元格列数
            itemStandard = sheet.Cells (rowValue, 3).Value#得到itemId对应的标准值                
            break
        else:
            i = i+1
    app.ActiveWorkbook.Close()
    #book.Close()
    #app.Quit()
    return itemStandard

相关推荐

    python3.12.2版本

    python3.12.2版本

    Python跳水

    Python跳水

    python2.7.17安装包

    python2.7.17安装包

    python3.8 基础镜像

    python3.8 基础镜像

    Python 八股文.pdf

    python八股文

    Python学习笔记(干货) 中文PDF完整版.pdf

    1、Python环境搭建 1.1 Python简介 1.2 Python语言的发展历程 1.3 Python语言的主要特点 1.4 Python应用场景 1.5 Python环境搭建 1.6 第一个Python程序 1.7 集成开发工具 2、Python语法基础 2.1 Python中的...

    ubuntu安装python3.9 ubuntu安装python3.9

    ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9 ubuntu安装python3.9

    智能问答系统python实现

    基于知识图谱的智能问答系统python实现(复旦大学论文基于qa语料和知识库的问答系统)_python 智能问答,python 智能问答系统-机器学习代码类资源本代码实现是基于python实现的基于复旦大学崔万云博士的learing ...

    python 3.10.11

    python官网下载的python3.10.11,包含以下python安装包: Gzipped source tarball XZ compressed source tarball macos 64-bit universal2 installer Windows embeddable package (32-bit) Windows embeddable ...

    Python必备背记手册

    Python必备背记手册

    ADS-PYTHON

    ADS-PYTHON-

    斯巴达Python

    斯巴达Python

    Python BBS论坛源码 Python源码

    Python BBS论坛源码 Python源码Python BBS论坛源码 Python源码Python BBS论坛源码 Python源码Python BBS论坛源码 Python源码Python BBS论坛源码 Python源码Python BBS论坛源码 Python源码Python BBS论坛源码 Python...

    Python3.6.4

    Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4Python3.6.4...

    programming python

    programming python 4th edition, python学习教程,python应用

    python3.6.4

    Python3.6 中文文档.pdf python364rc1.chm

Global site tag (gtag.js) - Google Analytics