Iam doing a project in django where i ha开发者_如何转开发ve to concatenate some log files and place it in the new file. How to create a file using shell commands in django???
Django, is just a Python framework. So, what you can do in Django is pretty much what you can do in Python.
In Python, the way to open (and create) files is with open(filename, mode)
.
>>> f = open('testing', 'w')
After you have a file object, you can write on it, and after doing everything you needed to do, close it.
>>> f.write('Hello world!')
>>> f.close()
>>> f = open('testing', 'r')
>>> f.read()
'Hello world!'
精彩评论