我正在编写一个脚本来自动进行网格划分,并需要以某种格式输出一个文本文件。我在三个引号前使用了F,但它说在代码末尾关闭file.write()时出现语法错误。不知道为什么。提前谢谢
with open('/Users/aben/blockMeshDict','w') as file:
file.write(F'''
FoamFile
{{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}}
convertToMeters 1;
vertices
(
(0 0 -0.1)
(0.6 0 -0.1)
(0 0.2 -0.1)
(0.6 0.2 -0.1)
(3 0.2 -0.1)
(0 1 -0.1)
(0.6 1 -0.1)
(3 1 -0.1)
(0 0 0.1)
(0.6 0 0.1)
(0 0.2 0.1)
(0.6 0.2 0.1)
(3 0.2 0.1)
(0 1 0.1)
(0.6 1 0.1)
(3 1 0.1)
);
blocks
(
hex (0 1 3 2 8 9 11 10) ({x0} {y0} 1) simpleGrading (1 1 1)
hex (2 3 6 5 10 11 14 13) ({x1} {y1} 1) simpleGrading (1 1 1)
hex (3 4 7 6 11 12 15 14) ({x2} {y2} 1) simpleGrading (1 1 1)
);''')
目前没有回答
相关问题 更多 >
编程相关推荐