mirror of
https://gitee.com/willfree/folder-file-manager.git
synced 2026-06-15 14:05:01 +08:00
‘模拟的中国985高校核心科研内容网站’自动化构建脚本
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import xlsxwriter
|
||||
import xlrd
|
||||
|
||||
|
||||
# 读取excel文件某一列
|
||||
def readExcelByCol(path, i):
|
||||
i_col_content = []
|
||||
worksheet = xlrd.open_workbook(path)
|
||||
sheet_names = worksheet.sheet_names()
|
||||
print(sheet_names)
|
||||
for sheet_name in sheet_names:
|
||||
sheet = worksheet.sheet_by_name(sheet_name)
|
||||
rows = sheet.nrows # 获取行数
|
||||
print(rows)
|
||||
for j in range(rows):
|
||||
i_col_content.append(sheet.cell_value(j, i))
|
||||
return i_col_content
|
||||
|
||||
# 创建excel文件
|
||||
def mkExcel(path):
|
||||
workbook = xlsxwriter.Workbook(path)
|
||||
workbook.close()
|
||||
print("--- Created excel success" + path + " ---")
|
||||
|
||||
|
||||
# 创建新文件。如果原来已经存在文件,则覆盖掉原有文件
|
||||
def mkfileCoverOriginFile(path,content):
|
||||
file = open(path, 'w')
|
||||
file.write(content)
|
||||
file.close()
|
||||
print("--- Created file success" + path + " ---")
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user