Recently, I have been studying python3 for a long time. It is suitable for students who have some programming foundation.

# know python

The same task requires 1000 lines of code in C, 100 lines in Java, and maybe 20 lines in Python.

So what kinds of applications is Python suitable for?

The first choice is network applications, including websites, background services and so on; Secondly, many daily needs of small tools, including system administrators need script tasks and so on;

# to install python

If Homebrew is installed, run the brew install python3 command to install Homebrew.

# # the python interpreter

Python code requires an interpreter to interpret the running program. The common interpreter is CPython. CPython is installed by default if you download it from the official website

Other interpreters:

  1. IPython
  2. PyPy
  3. Jython
  4. IronPython

Run the first program

The command is python3. Windows you go to the console and you type python code

>>> 100+200
300
Copy the code

The print() function prints printed text

>>> print('hello, world')
hello, world
Copy the code

## File writing

On Mac and Linux you can execute by double-clicking the py file.

You need to add a special comment to the first line of the.py file: helloworld.py

#! /usr/bin/env python3

print('hello world')
Copy the code

Then, give helloworld.py execution permission with the command:

$ chmod a+x hello.py
Copy the code

Windows, MAC, and Linux can also run Python files with commands

Pyhton3 file. PyCopy the code

Please follow the likeDev public account on wechat for more highlights.