2017年8月26日 星期六

[Python] Hello world in VSCODE

 Python   Visual Studio Code   


Introduction


Let’s see how to get the VSCODE ready for developing Python.


Configuration


Install Python

Go to Python.org and install it.



Install Python packages

Pylint: source code analyzer

$ python –m pip install pylint


autopep8: formats Python code to conform to the PEP 8 style guide

$ python –m pip install autopep8




Install VSCODE extensions
















Implement


Create a *.py file and write some codes.

# Number
num1 = 10
num2 = 20
num1 += 5
num2 += 5
sum = num1 + num2
print("Total = " + str(sum))

# Array
list = []
list.append("JB")
list.append("Lily")
list.append("Leia")
list.append("Hachi")
list.remove("Hachi")
for value in list:
    print("Name : " + value)




We will see the coding error message from Pylint.



And use Shift+ALT+f to format the codes.

After the codes are done, press F1 and key in “run code” to run the codes.
(Or use hot keys as the following picture)






Result

[Running] python "e:\Works\Source control\Github\KarateJB\Python.Practice\src\helloworld.py"
Total = 40
Name : JB
Name : Lily
Name : Leia

[Done] exited with code=0 in 0.159 seconds




Reference






沒有留言:

張貼留言