Python 碎记
An interpreter is a kind of program that executes other programs. When you write a Python program, the Python interpreter reads your program and carries out the instructions it contains. In effect, the interpreter is a layer of software logic between your code and the computer hardware on your machine.(是一个逻辑层的概念,在硬件和code之间进行解释交互)
The python code running:
Specifically, it’s first compiled to something called “byte code” and then routed to something called a “virtual machine.”
程序先被编译成为“字节码”,然后发送到“虚拟机”中运行,下面是运行过程:
字节码是python的一种特殊的表现形式,不同于C、C++等的机器能直接执行的bit码,字节码还是需要PVM进行解释之后才能执行。
This is python can be do in the world:
Python code can invoke C and C++ libraries, can be called from C and C++ programs, can integrate with Java and .NET components, can communicate over frameworks such as COM and Silverlight, can interface with devices over serial ports, and can interact over networks with interfaces like SOAP, XML-RPC, and CORBA. It is not a standalone tool
能够唤醒C、C++库,能够调用C、C++程序,能够和Java 、.Net等容器融合。
what we can do ?
1、Shell tools
it means that Python is a tool for coding operating-system-oriented scripts. Such programs are often launched from console command lines and perform tasks such as processing text files and launching other programs.
2、Control language
python有着类似于“胶水”作用,用于程序之间的粘合,在重要的节点执行可以免除一些模块的重复编译,有类似于调度资源的功能
3、Ease of use
faster、quick、
give people a tool, and they’ll code for a day; teach them how to build tools, and they’ll code for a lifetime.
Who use python today?
·Google makes extensive use of Python in its web search systems
·The popular YouTube video sharing service is largely written in Python
full-blown web development framework packages for Python, such as Django, TurboGears, web2py, Pylons, Zope, and WebWare, support quick construction of full-featured and production-quality websites with Python
python 的用途:
1、系统编程python程序善于查找,可以查询文件和目录结构树,链接其他的程序,对线程进行并发处理,所以适合于系统编程
2、GUI
not commonly use
3、网络脚本(网络编程)
python有网络模块,客户端和服务端都有modes,成熟的网络编程框架Django, TurboGears, web2py, Pylons, Zope, and WebWare
4、数据挖掘
可以与数据库进行对接
函数:
其实是对程序进行的一种优化,将需要反复使用的代码用“函数”包裹起来,降低了重复代码的书写,也是一种降低耦合的概念,只 需要修改代码时也只需要对少量的代码进行修改.