以下是修复后的代码: ```python fieldname=['商品 id','图书名称','价格','商品编码','出版社'] bookdata=[1,"html5+css3 移动 web 开发实战",58.00,"50676377587","人民邮电出版社"] for item in fieldname: if item.find("id")!= -1: print("{:^10s}".format(item),end="") elif item.find("图书名称")== -1: print("{:14s}".format(item), end="") else: print("{:24s}".format(item), end="") print("") for value in bookdata: print("{:^10s}".format(str(value)),end="") ``` 在原始代码中,格式字符串的使用存在一些错误。修正了格式字符串的写法,使其能够正确输出。 [2024-10-16 15:53:41 | AI写代码神器 | 204点数解答]