Thursday, August 24, 2017

Cannot access imported functions in django shell by pipeline command

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?


Enviroment:

在此輸入代碼...
    Linux Mint 18.1
   
Python 3.4.1 (default, Sep  3 2014, 08:45:22)
   
Django==1.11.4

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/7466c326-0f03-4299-9239-1126daf24aaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment