2015-02-09 72 views
3

我想根據不同的id號指定文件名。我如何根據不同的id值設置不同的文件名?Lua:用變量指定文件名

id = args.bdp_id 
filename = "./temp/vtx_vel%d.dat", id 
print (filename) 

回答

3

你可以這樣說:

filename ="./temp/vtx_vel"..id..".dat" 
+0

非常感謝你 – Kan 2015-02-10 05:11:54

3

string.format如果你想用sprintf風格換人:

filename = string.format("./temp/vtx_vel%d.dat", id) 
+0

非常感謝你 – Kan 2015-02-10 05:11:20