![](/img/trans.png)
[英]How can I export a list of association rules to txt or Excel in Python?
[英]How can I export data from Python to .txt?
我是一个新的 Python 用户,我有一个关于从 Python 导出数据的问题。 我编写了一个代码来使用 Delaunay 三角剖分创建网格。 对于三角测量,我使用了 matplotlib.tri 库。 我得到了一个网格的 plot,现在我想保存节点和元素的坐标。 所以我保存了节点列表:
#saving data
data = np.array([mesh_x, mesh_y]) #mesh_x and mesh_y - nodes that used in triangulation
data = np.transpose(data)
np.savetxt('nodes_data.txt', data, delimiter = ',')
现在我想保存元素,每个元素都包含两个节点,因为我考虑桁架元素。 您有什么建议,我如何将元素导出到 .txt 文件?
我对您的问题的最佳理解使我得到了这个答案
In [7]: import numpy as np
...: from matplotlib.tri import Triangulation
...: np.random.seed(sum(ord(c) for c in 'gboffi'))
...: x, y = [np.random.random(10) for _ in (0,0)]
...: tri = Triangulation(x, y)
...: print(tri.edges)
[[1 0]
[2 1]
[4 0]
[4 1]
[5 0]
[5 1]
[5 2]
[6 0]
[6 3]
[6 4]
[7 3]
[7 4]
[7 6]
[8 1]
[8 2]
[8 4]
[8 7]
[9 0]
[9 3]
[9 6]]
In [8]:
这是你想要的吗?
PS 我读过你的一个隐藏评论:Abaqus/CAE 有更好的网格支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.