基本上,这是我们合作者提供的用于生成网格的Python代码,它是在Linux环境下开发的。我使用 Cygwin 在 Windows 上运行此代码。麻烦部分如下。 BiV_temp.geo 也是一个 python 脚本。因此该命令是将脚本 BiV_temp.geo 中的字符串 <> 替换为预定义的数字和文件名。
os.system('cp BiV_fiber.geo BiV_temp.geo')
cmd = "sed -i 's/<<Meshsize>>/"+"%5.2f"%(meshsize)+"/g' BiV_temp.geo"
os.system(cmd)
cmd = "sed -i 's/<<LVfilename>>/"+"\"%s\""%(LVendocutfilename)+"/g' BiV_temp.geo"
os.system(cmd)
cmd = "sed -i 's/<<RVfilename>>/"+"\"%s\""%(RVendocutfilename)+"/g' BiV_temp.geo"
os.system(cmd)
cmd = "sed -i 's/<<Epifilename>>/"+"\"%s\""%(epicutfilename)+"/g' BiV_temp.geo"
os.system(cmd)
cmd = "gmsh -3 BiV_temp.geo -o %s"%(mshfilename)
os.system(cmd)
cmd = "rm BiV_temp.geo"
os.system(cmd)
最佳答案
合理的解决方案是让您的“协作者”编写 Python 代码,该代码允许您将这些内容作为参数传递给函数调用。
关于python - 当我运行 python 代码时,它显示 “<< was unexpected at this time",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34803504/