If csvfile is a file object, it should be opened with newline=''.

with open(r'C:\Users\Hanju\Desktop\uploadPortal(5).csv',"w", newline='') as _csvfile:
writer = csv.writer(_csvfile)

相关文章: