33 lines
732 B
Python
33 lines
732 B
Python
# -*- encoding: utf-8 -*-
|
||
import os
|
||
import sys
|
||
|
||
|
||
# 用于环境检查
|
||
# 检查Python版本
|
||
# 检查Python模块,需要xlrd
|
||
def check_env():
|
||
|
||
# 检查input文件夹
|
||
input_dir = os.path.join(os.getcwd(), 'input')
|
||
if not os.path.exists(input_dir):
|
||
os.mkdir(input_dir)
|
||
|
||
# 检查xlrd模块
|
||
try:
|
||
import xlrd
|
||
except:
|
||
print(u'缺少xlrd模块,将自动安装...')
|
||
# 执行安装
|
||
p = os.popen('pip install xlrd')
|
||
print(p.read())
|
||
import xlrd
|
||
finally:
|
||
print('***************************')
|
||
print(u'环境配置正常,可以运行转换工具')
|
||
print('***************************')
|
||
|
||
if __name__ == "__main__":
|
||
check_env()
|
||
|