Home > database >  The first Python program
The first Python program

Time:10-28

Python was born
Python is an object-oriented interpreted computer programming language, by the Dutch GuidovanRossum in
Invented in 1989, the first public version released in 1991, Python is a purely free software, source code reconciliation
Interpretation of the retaining follow the GPL (GNUGeneralPublicLicense) protocol,
Python syntax is concise and clear, the characteristic is one of the compulsory use whitespace (whitespace) as a statement indentation, Python has
Is rich and powerful, it has often been nicknamed glue language,


Before you start writing python, let's do some preparation work, the first is a python environment (before we have finished),
The second is the need to an editor
We use the
Notepad tools and command line to complete (the feeling of practice we write code and ability, is very important), we here in the notepad
Tools use sublime does or EditPlus, these tools to use are pretty good with,
Sublime does installation is not to say, everyone can find individuals has been configured to the net of the plug-in, as for the need to
To other plug-ins, such as the back when we need besides,
Create a folder on your computer,
After inside to create a file,
Note that
The file in English best
Naming,
The suffix is. Py
(. P y is the abbreviation of python,
All the python file suffix is py,
Is the equivalent of Java
File is. Java suffix),


CodePudding user response:

# - * - coding: GBK - * -

The import OS
The import sys
The import time
The import shutil
The import of logging

Logging. BasicConfig (level=logging DEBUG, format='% (asctime) (name) s - s - % % (the message) s')
Logging. The info (' to start the daemon)
Logging. The info (' daemon ready... ')
Ppath=OS. The path. The dirname (__file__)
Dpath=OS. Path. Join (ppath, 'the report')
While True:
Flist=OS. Listdir (dpath)
If len (flist) & gt; 0:
Logging. The info (' % d found a need to deal with file! ', len (flist))
For fname flist in:
Rpath=OS. Path. Join (dpath, fname)
If OS. Path. Isfile (rpath) :
OS. The system (" python report. Py "+ rpath)
Shutil. Move (rpath, ppath)
Time. Sleep (10)
If len (flist) & gt; 0:
Logging. The info (' daemon ready... ')
  • Related