我试图在 Django 中附加一个文件来进行字符串替换,由于某种原因它没有写入文件。阅读没有问题。
视图.py
with open('/home/me/dev/Django/rulebase/result.rb', 'a') as discover_reading:
mydiscover = File(discover_reading)
for line in mydiscover:
line.replace('input = "', 'this')
mydiscover.closed
我在浏览器上收到此错误:
Exception Type: IOError
Exception Value:
File not open for reading