zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    .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


    Flag Counter

    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    warning: a non-numeric value encountered in line *的解决方法
    给opencart产品页添加额外信息
    3种检测页面是否符合amp标准的方法
    opencart3修改产品页模板没有效果的原因排查
    opencart 3添加pdf文档下载功能
    opencart3属性attribute实现换行等简单html代码
    opencart分类筛选逻辑修改为并且条件
    opencart3产品页调用upc/数量等信息
    opencart3调用三级菜单level 3 sub categories
    点击鼠标出现漂浮字体("自信", "自强", "坚持"...)效果实现
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/13443217.html
Copyright © 2011-2022 走看看