Python Script:

1. Add some lines into a blank file: 

  echo "hello world" >> text.txt.

  Everytime before create a script file. we have some steps:

  a. Create a .script file by using mkdir text.script

  b. add some lines into the script to make sure the file is allowed to run under the shell:

    echo 'if __name__ == "__main__":\n    print("Welcome to a Python script")' > script.py # here we are using single bracket on each side of echo word.Pay attention that there are four space before print.

    

2.  We can use python2 to call the script:

  python text.script 

   Or use python3 to call the script:

  python3 text.script 

  Here, we can use python3 or python2 to call the script. But sometimes, if several project want to call a same library in different version. 

3.  Why we want to use virtual environment:

  

 So if we use virtual environment:

    

 

    

posted on 2016-11-02 06:21  阿难1020  阅读(101)  评论(0编辑  收藏  举报