I need your help python code to create new file (blank) just name from a list.
my_list = ['jordan', 'bella', 'anabelle']
we want to create
- jordan.html
- bella.html
- anabelle.html
thank you so much everyone
I need your help python code to create new file (blank) just name from a list.
my_list = ['jordan', 'bella', 'anabelle']
we want to create
thank you so much everyone
(Edited: for importing and iterating) if you want to iterate through a list:
with open('a.txt') as f:
a = f.read().split(' ')
for i in a:
with open(i + '.html', 'w') as f:
pass
with open("names.txt") as f:
my_list = f.readline().split()
for item in my_list:
with open(item+'.html', 'w') as fp:
pass
import os
class IO:
def __init__(self):
self.data = open("names.txt").readline().split()
def show(self):
return self.data
def create_files(self):
for i in self.data:
os.system("touch " + str(i) + str(".html"))
io = IO()
print(io.create_files())
Try this....and in names.txt just put blank space between names