我正在写一个程序,使音乐专辑成文件,你可以搜索,并为此我需要一个str在文件中有一个特定的值,是在列表完成后作出。你能回到那个列表,用一个新的值改变一个空白的str吗
我在网上搜索到一个叫做words.replace的东西,但是它不起作用,我得到了一个属性错误
def create_album():
global idnumber, current_information
file_information = []
if current_information[0] != 'N/A':
save()
file_information.append(idnumber)
idnumber += 1
print('Type c at any point to abort creation')
for i in creation_list:
value = input('\t' + i)
if value.upper == 'C':
menu()
else:
-1file_information.append('')
file_information.append(value)
file_information.append('Album created - ' + file_information[2] +'\nSongs:')
-2file_information = [w.replace(file_information[1], str(file_information[0]) + '-' + file_information[2]) for w in file_information]
current_information = file_information
save_name = open(save_path + str(file_information[0]) + '-' + str(file_information[2]) + '.txt', 'w')
for i in file_information:
save_name.write(str(i) + '\n')
current_files_ = open(information_file + 'files.txt', 'w')
filenames.append(file_information[0])
for i in filenames:
current_files_.write(str(i) + '\n')
id_file = open(information_file + 'albumid.txt', 'w')
id_file.write(str(idnumber))
-1是我放一个空行的地方
-2是我尝试用第0行和第2行的值替换列表中第1行的位置
我收到的错误消息是“int”对象没有属性“replace”
你试过这个吗
相关问题 更多 >
编程相关推荐