I upload a txt file to array and then I upload the array to a website, that downloads a file to a specific directory. The file name contains first ten letters of a array line. Problem: add number in 00n format before the file name. I tried several tips here but nothing works as I wished. In txt file are random sentences like "Dog is barking"
def openFile():
with open('test0.txt','r') as f:
content = f.read().splitlines()
for line in content:
line=line.strip()
line=line.replace(' ','+')
arr.append(line)
return arr
def openWeb()
for line in arr:
url="url"
name = line.replace('+', '')[0:9]
urllib.request.urlretrieve(url, "dir"+"_"+name+".mp3")
so the output should look like
'001_nameoffirst'
'002_nameofsecond'
arrobject to your question.arror at least some samples."{:03}_{}".format(23, "name")evaluates to"023_name"