这是执行的截图:
如您所见,错误显示目录"JSONFiles/Apartment/Rent/dubizzleabudhabiproperty"不存在.
但是看看我的文件,请:
文件夹肯定在那里.
代码
self.file = open("JSONFiles/"+ item["category"]+"/" + item["action"]+"/"+ item['source']+"/"+fileName + '.json', 'wb') # Create a new JSON file with the name = fileName parameter
line = json.dumps(dict(item)) # Change the item to a JSON format in one line
self.file.write(line) # Write the item to the file
Run Code Online (Sandbox Code Playgroud)
当我将文件名更改为较小的文件名时,它可以正常工作,因此问题在于路径的长度.请问是什么解决方案?