用Python处理Flutter中的图片路径编写

2019-08-05  本文已影响0人  Victory_886

图片处理

import os
import glob

index = 0
img_list = [];
path = str(os.getcwd())
print("图片路径为:"+path + '/imgs/img01/\n\n')
imagelist = sorted(glob.glob(path+'/imgs/img01/' + '*.*'))
for img in imagelist:
    index += 1
    img_path = str(img).replace(path, "")
    image_name = "static const model_img_name_"+str(index)+"<##> = \"" + img_path + "\";"
    img_list.append(image_name)
    print("\""+img_path+"\"")

print("\n\nflutter 定义如下:")
for s in img_list:
    print(s)

就这点儿代码省我们很多的手动编写的时间,如今的时代时间就是生命,拿去用吧~~
加油哦!!!
青年~~

上一篇 下一篇

猜你喜欢

热点阅读