我在python中有此代码,我必须在c ++中进行翻译,但是我被困住了,因为我无法弄清楚如何无法在python中初始化像这样的列表以及如何在类似以下代码的文件中写入
def to_file(sy, ey, sx, ex, name, dor):
rBloc = ["LINE\n", "8\n", str(dor) + "\n",
"10\n" + str(sx) + "\n" + "11\n" + str(ex) + "\n" +
"20\n" + str(sy) + "\n" + "21\n" + str(ey) + "\n" +
"0\n"]
with open(files.result_directory + r"\box_" + name[:-1] + ".dxf", "a") as f:
for i in rBloc:
f.write(str(i))
您可以使用C ++向量替换python中的列表。整个代码将如下所示。