刚刚看sumo的官方教程,有一段代码是生成配置文件,发现python中的print函数也可以写文件。
with open("data/cross.rou.xml", "w") as routes: print("""<routes> <vType \ guiShape="passenger"/> <vType /> <route /> <route /> <route , file=routes)
其中三引号的作用之前文章写过,是为了保证代码中的换行效果能正常导出
刚刚看sumo的官方教程,有一段代码是生成配置文件,发现python中的print函数也可以写文件。
with open("data/cross.rou.xml", "w") as routes: print("""<routes> <vType \ guiShape="passenger"/> <vType /> <route /> <route /> <route , file=routes)
其中三引号的作用之前文章写过,是为了保证代码中的换行效果能正常导出
相关文章: