Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果您有 write.row 命令:
writer.writerow(row)
在 for 循环中,如何在第 2 列第 2 行开始写入?我想在第 2 列第 1 行放置一个标题,并保留第 1 列中的内容
在这里,我假设您的标头是一组长度为len(columns)1 的标记:
len(columns)
for rown, row in enumerate(csv_file): if != 1: writer.writerow(row) else: cols = [] for col in enumerate(row): cols.append(col) break cols.append(header) # append header cols writer.writerow(','.join(cols))