.pyc & Python
.pyc & Python
Python bytecode / 字节码
Python compiles the .py files and saves it as .pyc files , so it can reference them in subsequent invocations.
The .pyc contain the compiled bytecode of Python source files, which is what the Python interpreter compiles the source to.
This code is then executed by Python's virtual machine . There's no harm in deleting them (.pyc), but they will save compilation time if you're doing lots of processing.
Python会编译.py文件并将其保存为.pyc文件,因此它可以在后续调用中引用它们。
.pyc包含Python源文件的已编译字节码,这是Python解释器将源代码编译到的字节码。
然后,此代码由Python的虚拟机执行。删除它们(.pyc)没有什么害处,但是如果您要进行大量处理,它们将节省编译时间。
test.py
# coding: utf8
__author__ = 'xgqfrms'
__editor__ = 'vscode'
__version__ = '1.0.1'
__copyright__ = """
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
"""
class Test(object):
def sum(a, b):
return a + b
test.pyc
�
�*_c�����������@���s2���d��Z��d�Z�d�Z�d�Z�d�e�f�d�������YZ�d�S(���t���xgqfrmst���vscodes���1.0.1s@���
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
t���Testc�����������B���s���e��Z�d�����Z�RS(���c���������C���s���|��|�S(���N(����(���t���at���b(����(����s@���/Users/xgqfrms-mbp/Documents/GitHub/Python/spider/spider/test.pyt���sum
���s����(���t���__name__t
���__module__R���(����(����(����s@���/Users/xgqfrms-mbp/Documents/GitHub/Python/spider/spider/test.pyR��� ���s���N(���t
���__author__t
���__editor__t���__version__t
���__copyright__t���objectR���(����(����(����s@���/Users/xgqfrms-mbp/Documents/GitHub/Python/spider/spider/test.pyt���<module>���s���
env
声明为可执行文件, 不会编译成字节码
#! /usr/bin/env python
# 声明为可执行文件
# coding: utf8
__author__ = 'xgqfrms'
__editor__ = 'vscode'
__version__ = '1.0.1'
__copyright__ = """
Copyright (c) 2012-2050, xgqfrms; mailto:xgqfrms@xgqfrms.xyz
"""
class Test(object):
def sum(a, b):
return a + b
refs
http://net-informations.com/python/iq/pyc.htm
https://stackoverflow.com/questions/2998215/if-python-is-interpreted-what-are-pyc-files
https://en.wikipedia.org/wiki/Pyc
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
.pyc & Python的更多相关文章
- python如何编译py文件生成pyc、pyo、pyd以及如何和C语言结合使用
python执行py文件的流程 当我们执行一个py文件的时候,直接python xx.py即可,那么这个流程是怎么样的呢.先说明一下,python执行代码实际上是先打开文件然后执行里面的代码,所以文件 ...
- Python Day02
Python 代码执行流程: 编译 --> 执行 源代码 --> 字节码 --> 机器码 --> CPU执行 python 先将自己的源代码,编译成Python 字节 ...
- python环境搭建-Linux系统下python2.6.6升级python3.5.2步骤
[root@template ~]# python -v # /usr/lib64/python2.6/encodings/utf_8.pyc matches /usr/lib64/python2.6 ...
- (Python )模块、包
本节开始学习模块的相关知识,主要包括模块的编译,模块的搜索路径.包等知识 1.模块 如果我们直接在解释器中编写python,当我们关掉解释器后,再进去.我们之前编写的代码都丢失了.因此,我们需要将我们 ...
- 无需操作系统和虚拟机,直接运行Python代码
Josh Triplett以一个“笑点”开始了他在PyCon 2015上的演讲:移植Python使其无需操作系统运行:他和他的英特尔同事让解释器能够在GRUB引导程序.BIOS或EFI系统上运行.连演 ...
- python编译以及反编译
在Python2.3之前Python自带反编译的工具,高版本的貌似这个反编译的已经不能用了. 据说是在Python2.7上最好用的反编译工具uncompyle 代码地址 http://github.c ...
- Python进阶之路---1.4python数据类型-数字
python入门基础 声明:以后python代码未注明情况下,默认使用python3.x版本 1.python代码基础:print print('hello,python') 1.1pyt ...
- robot framework用python扩展编写自定义library
我的utils.py文件 #!/usr/bin/env python #-*- coding:utf8 -*- __version__ = '0.1' import sys reload(sys) s ...
- Python第一天 安装 shell 文件
Python第一天 安装 shell 文件 python里面一切都是对象 object 代码缩进:建议用四个空格来缩进,不要用tab键 安装 Linux自带python,windows需要下载m ...
随机推荐
- 内存空间有限情况下的词频统计 Trie树 前缀树
数据结构与算法专题--第十二题 Trie树 https://mp.weixin.qq.com/s/nndr2AcECuUatXrxd3MgCg
- 1、剑指offer-数组——二维数组中的查找
*题目描述* **在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含 ...
- java中List元素移除元素的那些坑
https://blog.csdn.net/javageektech/article/details/96668890 List 的迭代器类 采用倒序移除 jdk1.8的写法 public sta ...
- K8s 一、(1、容器基本概念 2、k8s基本概念 )
1.容器基本概念 容器其实就是一种特殊的进程,容器是一个 '单进程'模型. Namespace :隔离 Namespace 技术实际上修改了应用进程看待整个计算机"视图",即它的& ...
- hibernate+spring+tomcat启动报错Not supported by BasicDataSource
最近使用hibernate+spring+jsp的小项目制作过程中出现一些错误,例如: java.lang.UnsupportedOperationException: Not supported b ...
- 使用mybatis自动实现接口封装返回结果集
import java.lang.annotation.Annotation; import java.lang.annotation.Documented; import java.lang.ann ...
- linux系统find命令详解+xargs命令 、exec命令
find 作用:查找文件 1.name: 指定文件名 例子1. 找到以du结尾的文件 ╭─root@localhost.localdomain ~ ╰─➤ find / -name "*du ...
- Linux系统对文件及目录的权限管理(chmod、chown)
本文命令: 4 5 6 ls -l chmod chown 1.身份介绍 在linux系统中,对文件或目录来说访问者的身份有三种: ①.属主用户,拥有者(owner)文件的创建者 ②.属组用户,和文件 ...
- UI自动化实战进阶PO设计模式
前言 经过前面的实战我们已经编写了几个测试用例,下面我们要用PO设计模式来调整我们的代码,让页面元素和测试业务进行分离,这样看起来直观而且后期的维护也方便. python有一个第三方的PO设计的库,既 ...
- Flink-v1.12官方网站翻译-P014-Flink Architecture
Flink架构 Flink是一个分布式系统,为了执行流式应用,需要对计算资源进行有效的分配和管理.它集成了所有常见的集群资源管理器,如Hadoop YARN.Apache Mesos和Kubernet ...