forked from qiwsir/StarterLearningPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,8 +158,18 @@ Hello,World.是面向世界的标志,所以,写任何程序,第一句一 | |
|
||
是不是在为看到自己写的第一个程序而欣慰呢? | ||
|
||
##编译过程 | ||
|
||
在刚才的程序中,那些东西我们可以笼统称之为源代码,最后那个扩展名是`.py`的文件是源代码文件。Python是如何执行源代码的呢? | ||
|
||
![](./1images/10508.jpg) | ||
|
||
当运行`.py`文件的时候,Python会通过编译器,将它编译为`.pyc`文件,然后这个文件就在一个名为虚拟机的东西上运行,这个所谓的虚拟机是专门为Python涉及的,正是因为有了虚拟机,使得Python是跨平台的,也就是说你写的Python程序可以不经过修改而在不同才做系统上运行。如果你没有修改`.py`文件,那么每次执行这个程序的时候,就直接运行前面已经生成的`.pyc`文件,这样让执行速度就大大提升了,不是每次都要从新编译。有一些不了解或者不愿意了解Python的人,总认为Python使解释型语言,每次执行程序都要从头到位一行一行解释执行,这是对Python的无知表现。如果你修改了`.py`文件,下次执行程序的时候,会自动从新编译。 | ||
|
||
你根本不用关心`.pyc`文件,Python总是自动完成编译过程的。而且,它的代码因为使给机器看的,你也看不懂。不过要注意的是,不要删除它,也不用重命名。 | ||
|
||
------ | ||
|
||
[总目录](./index.md) | [上节:常用数学函数和运算优先级](./104.md) | [下节:字符串(1)](./106.md) | ||
|
||
如果你认为有必要打赏我,请通过支付宝:**[email protected]**,不胜感激。 | ||
如果你认为有必要打赏我,请通过支付宝:**[email protected]**,或者加我微信(**微信号:qiwsir**),不胜感激。 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.