阅读python的base64.py源代码

作为一个半吊子码农,我希望能够通过阅读base64.py的源代码来提高一下自己的姿势水平。代码大概600行,不过考虑到最近时间有些紧张,可能需要一段时间才能把这段代码看完。

阅读代码遇到的一个问题:不知道__all__这个变量是干嘛的。

到万能的google上一查,发现__all__主要影响from xxx import *这个命令,如果源文件里面没有__all__,那么用前面提到的命令导入的时候会把源文件里所有的变量都导入到当前的环境,如果设置了__all__那么只有指定的变量会导入到当前的环境中。

时间: 2024-08-24 08:03:53

阅读python的base64.py源代码的相关文章

安装python,setuptools,get-pip.py,ipython构建python开发环境

安装python,setuptools,get-pip.py,ipython,构建python开发环境 安装环境:Centos6.7 ,安装时选项为桌面,增加了开发工具包. 1.python2.7.11安装 下载源代码: wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz 安装: ./configure make make install 2.安装setuptools wget https://pypi.python.o

Python的__init__.py用法

python中包的引入,对于大型项目中都会使用到这个功能,把实现不同功能的python文件放在一起,组成不同lib库,然后在其他地方调用. 1.__init__.py基本介绍 首先看下面这个例子 例子1 #!/usr/bin/env python2.7 #-*- coding:utf-8 -*- from package.src.test import A a = A(2) a.aPrint() 从package包中的src子包中test.py文件中,引入A类,如何实现这一点?? 需要构建如下的

python解析百度网页源代码:取搜索引擎返回的前page_num*10个链接的url

如题:python解析百度网页源代码:取搜索引擎返回的前page_num*10个链接的url 最近因为做<信息检索>homework,需要在搜索引擎中搜索某个query,人工查找那些搜索引擎返回的链接,判断前30个是否相关,然后评价该搜索引擎的性能.蛋疼的一个个点进去链接,然后看网页搜索的内容是否和想要查询的query相关,从而进行下一步工作.于是想到解析网页,找到搜索引擎返回的链接的url,等做完了作业才做这个,无碍.目前分析了百度的源代码,进行了分析工作.对于其他搜索引擎的任务再分析. #

python的setup.py文件

最近工作需要,用Cython写了*.pyx扩展,并将其编译成C文件,最后转换为so扩展,供python引用 使用 distutils 编译,建立一个setup.py 的脚本 from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext setup( name = 'cython_build_test', cmdclass = {'b

用Python脚本监测.py脚本的进程状态,并实现中断重启。

用Python脚本监测.py脚本的执行状态,并实现中断重启. #!/usr/bin/python # -*- coding:utf-8 -*- import subprocess,time,sys TIME = 10                        #程序状态检测间隔(单位:分钟) CMD = "get_bjipku.py"                 #需要执行程序的绝对路径,支持jar 如:D:\\calc.exe 或者D:\\test.jar class Aut

python pip ez_setup.py

#!/usr/bin/env python """Bootstrap setuptools installation To use setuptools in your package's setup.py, include this file in the same directory and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools()

python 装 ez_setup.py 出错

python 装 ez_setup.py出错setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.解决:打开Python27\Lib\mimetypes.py在default_encoding = sys.getdefaultencoding() 前加后三行 if sys.getdefaultencoding() != 'gbk': reload(sys) sys.setdefaultencoding

第一个Python程序hello.py提示出现File &quot;&lt;stdin&gt;&quot;,line 1错误

写第一个Python程序hello.py,内容仅有一句,print 'hello world', 运行 Python hello.py 出错,提示: File "<stdin>" , line 1python hello.py SyntaxError:invalid syntax 原因: 在shell脚本中,运行shell脚本命令:在Python命令行中,运行Python代码.然而,"python hello.py"是一个脚本命令,不是python代码.

python附录-builtins.py模块str类源码(含str官方文档链接)

python附录-builtins.py模块str类源码 str官方文档链接:https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str builtins.py class str(object): """ str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str Create a new stri