Python Individual Learning notes one

Source: Internet
Author: User

A brief description of the environment


Under the Windows system, a Python script editing runtime environment is built, with the required tools platform as follows.

1.1Python Download website www. python. org. There are 2.x and 3.x versions. Their choice, grammatical slightly different.

1.2eclipse eclipse-jee-kepler-sr2-win32-x86_64 or eclipse-jee-luna-sr2-win32-x86_64 version.

1.3 Oracle website Download jdk JRE

1.4 http://www.pydev.org/Download Plugin

Specifically how to install a lot of online. Baidu, Google can.


Two auxiliary tool description.


I am using the python3.4 and Eclipse Pydev plug-in WIN8 64-bit system to make up the editing run environment.

Special description of a tool, I test practical. The py script file can be converted to the Windows System platform under the

PE program. Cx_freeze-4.3.3.win-amd64-py3.4.exe Use this tool to convert in command-line mode. Remember to add environment variables before use. (I install the command in the C:\\python34\\scripts\\ directory:

C:\python34\scripts>pythoncxfreeze-h

Usage:cxfreeze[options] [SCRIPT]

Freeze a pythonscript and all of their referenced modules to a base

Executable which Canthen be distributed without requiring a Python

Installation.

Options:

--version Show Program ' s version number Andexit

-H,--help show this help message and exit

-o optimize generated bytecodeas per pythonoptimize; Use

-oo in order to removedoc strings

-C,--compress compress byte code in ZIP files

-S,--silent suppress all output except Warningsand errors

--base-name=name file on which to base the target file; Ifthe Name of

The file is not anabsolute file name, the

subdirectory bases (rooted in the directory in which

The freezer is found) would be searched for a file

matching the name

--init-script=name script which would be executed upon startup;if the

Name of the file is Notan absolute file name, the

subdirectoryinitscripts (rooted in the directory in

which the cx_freezepackage is found) 'll be searched

for a file matching thename

--target-dir=dir,--install-dir=dir

the directory in Whichto place the target file and

any dependent files

--target-name=name The name of the file to create instead ofthe base

Name of the script andthe extension of the base

Binary

--no-copy-deps Do not copy the dependent files (extensions, shared

libraries, etc.) to Thetarget directory; This also

modifies the defaultinit script to consolekeeppath.py

and means that Thetarget executable requires a Python

installation to Executeproperly

--default-path=dirs List of paths separated by the standard PathSeparator

for the platform Whichwill is used to initialize

Sys.path prior to running Themodule Finder

--include-path=dirs List of paths separated by the standard PathSeparator

for the platform Whichwill is used to modify Sys.path

prior to running Themodule Finder

--replace-paths=directives

Replace all the Pathsin modules found in the given

paths with the givenreplacement string; Multiple

values is separated bythe standard path separator

and each of the value is ofthe form path=replacement_string;

Path can be * Whichmeans all paths not already

specified

--include-modules=names

Comma separated list ofmodules to include

--exclude-modules=names

Comma separated list ofmodules to exclude

--ext-list-file=name NAME of file in which to place the list ofdependent

files which were copied into the TargetDirectory

-Z SPEC,--zip-include=spec

Name of file to add tothe zip file or a specification

of the formname=arcname which would specify the

archive name to use; Multiple--zip-includearguments

can be used

--icon=icon Name of the icon file for theapplication

C:\python34\scripts>

Working with instances

Python cxfreezehello.py--target-dir DESTDIR//convert hello.py files to PE files.

The generated console console program is a Win32. You need to modify the setup.py file to generate a form program.

This file is installed when Cx_freeze is generated.

Import sysfrom cx_freeze Import setup, executable# Dependencies is automatically detected,but it might need fine tuning.b Uild_exe_options = {"Packages": ["OS"], "excludes": ["Tkinter"]}# GUI applications require a different Baseon Windows (the Default is for a# console application). Base = Noneif Sys.platform = = "Win32":   base = "Console" Setup (name = "Hello", 
   version = "0.1",       description = "My GUI application!",       options = {"Build_exe": build_exe_options},       executables = [Executable ("hello.py", Base=base)])

Three code tests


3.1 Output

Print ("HELLO World")//single double quotation mark line

3.2 Input

iNum = Int (input ())//conversion

3.3 Cycles

For I in range (n)://0-----n-1 Range

3.4 Function definitions

3.5 Class Definitions

Iv. description


The basic type of the Python language belongs to a weak type. On the statement block, according to the line break and carriage return, it is strictly judged. So you have to strictly define the modules that you write.


Python Individual Learning notes one

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.