[英]python create a text file with name from partial variable
I have the following variable 12345678901234567890
and I want to create a text file named with the part 78901
from the middle of the variable 123456(78901)234567890
我有以下变量
12345678901234567890
,我想从变量123456(78901)234567890
78901
的中间创建一个以部分78901
命名的文本文件
How I can do that ?我怎么能这样做?
Thanks谢谢
string = '12345678901234567890'
name = string[6:11]
with open(name, 'w') as f:
f.write("hello world")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.