On Aug 24, 2017 10:33 PM, "Cheng-Hung Hsueh" <[email protected]> wrote:

It is a python script `tshi3.py` :


在此輸入代碼...

    import csv
    def li2ho2():
        print(csv)
    li2ho2()


I copied this code and pasted it in `python manage.py shell`. It works.

But I ran `python manage.py shell < tshi3.py`. Got `NameError: name 'csv'
is not defined.`

Why?


I don't know if the 'manage.py shell' command supports what you are doing.
I would instead write a management command to run arbitrary code from the
command line.

https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUYgjGm5%2BNGByT2O9PjJvzGefuCEi0rYJf5AMPDiP%2Bj2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to