First install the Python version 3.4 with homebrew. Apple's own python, the development of words or forget it. Enter this line of command in the terminal.
install python3
Next open the sublime, and the syntax is changed to Python. Input
print (‘Hello World‘)
Note that in Python3, the print function needs to be enclosed in parentheses. For beginners who often use C,java, they may not be accustomed to using semicolons.
After you finish writing this line of code, open the terminal and enter the following code:
python xxx.py
Note that xxx here is the full path to the Python file. After successful operation, you can see the results of the operation in the terminal.
But soon there was a problem, like I wanted to output "1+2=3", where 3 was represented as a variable. Try to run the code like this:
print (‘100 + 200 = ‘ + (100+200))
Get the error message:
Typeerror:cannot concatenate ' str ' and ' int ' objects
The reason is that the Python3.4 version does not allow strings and numbers to be stitched together. The workaround is simple, by converting the int type to a string type through the bytes function.
The modified code is:
print (‘100 + 200 = ‘ + bytes(100200))
Run, everything OK.
100 + 200 = 300
Mac configures the Python development environment and implements simple string and integer stitching