function exists(f)
filetry=""
local fileBuffer={}
for w in x:gmatch("%S+") do
table.insert(fileBuffer,w)
end
for i, v in ipairs(fileBuffer) do
filetry=filetry.."_"..v
end
f=filetry
if os.execute("test -e "..f) == true then
return true
else
return false
end
end
我需要将空格字符更改为下划线 所以我可以在termanal找到该文件 我试图使用api但是它不适合我,因为我的电脑在安装后将其删除。所以我只需要一个可以创建空格,下划线的函数,并使用termanal test命令查找文件
答案 0 :(得分:3)
print( ("Hello world"):gsub("%s+", "_") )
-- will print "Hello_world"
示例:
str = str:gsub...
编辑:请注意,string.gsub()创建一个新字符串而不是修改旧字符串,这就是为什么在我的第一个示例中重新签名import numpy as np
import pylab as plt
f,ax = plt.subplots()
x = np.arange(10)
y = np.sin(x)
ax.plot(x,y, label = 'sin')
leg = ax.legend(fontsize = 'large')
leg.set_title("title", prop = {'size':'x-large'})
f.show()
是必要的。