When using Python, enter Python directly at the command line to enter Python interaction:
When importing a module, such as the Import OS, dir (OS) is required to see all the properties and methods of the OS.
Here is a program that enables you to press the TAB key to know all the methods of that module:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/84/wKiom1RSZObi7XrKAAHN0vz4hk4419.jpg "title=" tab completion file. jpg "alt=" wkiom1rszobi7xrkaahn0vz4hk4419.jpg "/>
You can do this by saving the above command line to a tab.py and then importing tab to the Python interaction line, and then import the other modules.
Locate tab.py locates the path to the program. More tab.py View the contents of the program.
There is no difference between single and double quotes in Python. Three quotation marks can be used to write higher-degree-of-freedom strings or to annotate.
(Single and double quotes in the shell are different, double quotes are used to reference variables.) )
Like echo "I am $year years old\!" (exclamation points need to be escaped)
There are three ways of importing modules:
-
Import Math (usage: math.sin ())
-
Impor Math as MT (usage: Math.sin ())
-
From Math Import * (usage: sin ())
Python User interaction:
Str=raw_input (). Strip () (Strip effect: Remove the whitespace before and after Str to make the program more robust. )
Int=input ()
For I in range (1,100): (Output 1 to 99)
Finish. (sudo/etc/init.d/httpd restart for restarting Apache server)
This article is from the "Blue Fin Dolphin" blog, please be sure to keep this source http://likunheng.blog.51cto.com/9527645/1569921
Python basic knowledge