0

我想问如何制作一个“python manage.py shell”并添加一个“from myapp.model import Contact c = Contact.objects.all().count() print c”。这可能在批处理文件中吗?

4

1 回答 1

2

尝试类似:

echo "from myapp.model import Contact; c = Contact.objects.all().count(); print c" | python manage.py shell

或者这个How do you read from stdin in Python?

于 2014-03-26T01:56:40.823 回答