使用变量作为保存文件名〜im.save(type,'.png') [英] Using a variable as a Save file name ~ im.save(type, '.png')

查看:642
本文介绍了使用变量作为保存文件名〜im.save(type,'.png')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我要输入的内容:

This is what I'm inputting:

type = 'filename'
im.save(type, '.png')

这应该是将文件保存为.png格式,但是使用变量作为名称,我只是不确定100%应该如何布置格式/语法.

and what this is supposed to do is save the file in a .png format but with the variable as the name, I'm just not 100% sure how the format/syntax is supposed to be laid out.

是否与我要打印变量一样?

Is it the same as if I wanted to print the variable:

Print(type, "This shows up beside the type I think")

编辑,不要太在意列表,它只是其中的一个例子.我不确定如何在像im.save(type,'PLAINTEXT')这样的纯文字单词旁添加变量

edit, Don't pay to much attention to the list, it's mostly there as an example. I not sure how to have a variable right beside a Plain text word like this im.save(type, 'PLAINTEXT')

推荐答案

如果您要使用PIL,请像这样使用它:

If you're trying to use PIL, please, use it like this:

file_name = 'my_file'
im.save( file_name + '.png' )

将导致my_file.png保存到磁盘.

这篇关于使用变量作为保存文件名〜im.save(type,'.png')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆