Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
CYDXDianXian authored Feb 13, 2022
1 parent 75bf5a8 commit 133950f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions image_transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
from pathlib import Path


source_folder = "img"
output_folder = "output"
img_type = input("请输入目标格式:") # input函数返回的是用户输入内容,为字符串类型,若需要计算数字,用int()或者float()函数转换数据类型
path_input = "img"
path_output = "output"

Path(path_input).mkdir(parents = True, exist_ok = True)
print('img文件夹已创建,请将待转换的图片放入img文件夹中')

path_input = Path(__file__).parent / source_folder
path_output = Path(__file__).parent / output_folder
img_type = input("请输入目标格式:") # input函数返回的是用户输入内容,为字符串类型,若需要计算数字,用int()或者float()函数转换数据类型

Path(path_output).mkdir(parents = True, exist_ok = True)

try:
path_list = [i for i in Path(path_input).iterdir()] # 当路径指向一个目录时,产生该路径下的所有对象的路径。iterdir()返回的是一个生成器,需要循环遍历才能读取
except FileNotFoundError:
print('文件目录下没有img文件夹,请创建文件夹并将图片放入img文件夹中')
time.sleep(5) # sleep操作,防止用户看不到打印消息程序就结束了
sys.exit()

def changeType():
Expand Down Expand Up @@ -53,6 +55,8 @@ def changeType():

print(f'全部转换完成!!!共成功{success_num}个,失败{error_num}个,用时{int(end - start)}秒')
print(f'文件输出路径:{path_output}')
print('程序将在10秒后结束......')
time.sleep(10) # sleep操作,防止用户看不到打印消息程序就结束了

if __name__ == "__main__":
changeType()
2 changes: 1 addition & 1 deletion install_requirements.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
start cmd /k pip install -i https://pypi.doubanio.com/simple/ -r requirements.txt
start cmd /k pip install -i https://pypi.doubanio.com/simple/ -r requirements.txt
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
start cmd /k py image_transcoding.py
start cmd /k py image_transcoding.py

0 comments on commit 133950f

Please sign in to comment.