38 lines
916 B
Python
38 lines
916 B
Python
import os
|
||
import sys
|
||
|
||
|
||
# 用于环境检查
|
||
# 检查Python版本
|
||
# 检查Python模块,需要xlrd
|
||
def check_env():
|
||
# 检查Python版本
|
||
if sys.version_info < (3, 0):
|
||
print('***************************')
|
||
print('ERROR: Python版本低于3.0')
|
||
print('***************************')
|
||
return
|
||
|
||
# 检查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('缺少xlrd模块,将自动安装...')
|
||
# 执行安装
|
||
p = os.popen('pip install xlrd')
|
||
print(p.read())
|
||
import xlrd
|
||
finally:
|
||
print('***************************')
|
||
print('环境配置正常,可以运行转换工具')
|
||
print('***************************')
|
||
|
||
if __name__ == "__main__":
|
||
check_env()
|
||
|