首页 > 代码库 > Command Line 3

Command Line 3

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:

    

技术分享

 

    

Command Line 3