Python Base Usage

Cause

: python简明教程(中文完整版-高清-带书签).pdf https://download.csdn.net/download/github_34103268/10207978

Install

download form official site: https://www.python.org/ then install, attention that select "ADD PATH'.

hello world program

Of cause, beter use the IDLE to coding, whitch can debugging, highline, and so on.

IDE

Suggest using VSCODE to coding, because vscode could confiure that code hinting like using vc++ through vs2008.

Confiure method:

If you using vscode open *.py file, will prompt you to install 'Python' extension, just install it as blow:

Then the result is:

Press "F5", python would execute.

When have wrong, will prompt you: (This is so good)

When you debuging program, don't need "Ctrl+S", just input "Shift+Ctrl+F5", would saved and reset to run.

Debug

Refer: https://pythonconquerstheuniverse.wordpress.com/2009/09/10/debugging-in-python/

1.Add in source code:

import pdb
pdb.set_trace()

Then will turn to debug mode, as below:

Then you could use command in command-line.

n
q
p
c
l
s
r

Switch python 3 to python 2

1.Down python 2.7 in  official site.

2.Use sbolute path. Such as add a "OpenPython2.7.bat" file, contain is

C:\Python27\python.exe

Or change the Environment Path Value (This way is better).

Change "C:\Python27\python.exe" to "C:\Python27\python2.exe"

Then add the path "C:\Python27\", so now you can derict use the command "python2".

(over)

posted on 2018-11-21 17:49  lizhuohui  阅读(49)  评论(0编辑  收藏  举报

导航