我想将文本(我从 AJAX 获得)写入一个文件,然后读取它。
最佳答案
如果您可以在 Django View 中使用它...请尝试这样的操作:
def some_view(request):
text = request.POST.get("text", None)
if text is not None:
f = open( 'some_file.txt', 'w+')
f.write(text)
f.close()
return HttpResponse()
关于python - 如何使用python读写文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2491141/