gpt4 book ai didi

python - np.savetxt - 使用变量作为文件名

转载 作者:太空宇宙 更新时间:2023-11-04 08:47:26 25 4
gpt4 key购买 nike

在使用 np.savetxt 时如何使用变量作为文件名

这是我的 MWE:

import numpy as np

k=0
x = [1, 2, 3]
y = [4, 5, 6]
zipped = zip(x, y)

np.savetxt('koo'+str(k)'.txt', zipped, fmt='%f\t%f')

但是这会抛出“无效语法”错误

最佳答案

np.savetxt('koo'+ str(k) + '.txt', zipped, fmt='%f\t%f')

您忘记了 + 符号。

关于python - np.savetxt - 使用变量作为文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38960124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com