Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 写入文件nodemcu lua_File_Variables_Lua_Esp8266_Nodemcu - Fatal编程技术网

File 写入文件nodemcu lua

File 写入文件nodemcu lua,file,variables,lua,esp8266,nodemcu,File,Variables,Lua,Esp8266,Nodemcu,我试图写入文件,然后读取其内容我使用的代码是: file.remove("CRED.lua") file.open("CRED.lua","w+") temp = "PASS = "..pass file.writeline(temp) temp = "SSID = "..ssid file.writeline(temp) file.flush() temp = nil file.close() 文件似乎已创建,但我执行此操作时: dofile("CRED.lua") print(PASS)

我试图写入文件,然后读取其内容我使用的代码是:

file.remove("CRED.lua")
file.open("CRED.lua","w+")
temp = "PASS = "..pass
file.writeline(temp)
temp = "SSID = "..ssid
file.writeline(temp)
file.flush()
temp = nil
file.close()
文件似乎已创建,但我执行此操作时:

dofile("CRED.lua")
print(PASS)
print(SSID)
我得到的两个值均为零。

您知道原因吗?

CRED.lua
文件中,您有:

PASS = <password stored in pass variable>
temp=“PASS=”(“%q”):格式(PASS)
file.remove("CRED.lua")
file.open("CRED.lua","w+")
temp = "PASS = \""..pass.."\""
file.writeline(temp)
temp = "SSID = \""..ssid.."\""
file.writeline(temp)
file.flush()
temp = nil
file.close()