我一直在尝试将输入的数据添加到 csv 文件中,我设法得到了它,输出是:
'j')
return name, age, position, salary, years
outfile.write(str(add_emp())[1:-1] + '\n')
作为一个肮脏的解决方案,您可以从您制作字符串的部分中删除撇号
outfile.write(str(add_emp())[1:-1] + '\n')
改成
outfile.write(str(add_emp()).replace("'", "")[1:-1] + '\n')
更多的pythonic方式是将它们连接在一起
outfile.write(' '.join(add_emp() + '\n')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句