1、format()
在保存图片时,路径可以写成这样:
import os from hashlib import md5 def save_image(content): file_path = '{0}/{1}.{2}'.format(os.getcwd(),md5(content).hexdigest(),'jpg') if not os.path.exists(file_path): with open(file_path,'wb') as f: f.write(content) f.close()
浙公网安备 33010602011771号