zoukankan      html  css  js  c++  java
  • python之模块base64

    # -*- coding: cp936 -*-
    #python 27
    #xiaodeng
    
    >>> help(base64)                #用来作base64编码解码
    FUNCTIONS                       #函数(功能)         
        •b16decode(s, casefold=False)
            Decode a Base16 encoded string.

          #解码
          decode_string=base64.b16decode('7869616F64656E67')
          print decode_string#xiaodeng

    
        •b16encode(s)
            Encode a string using Base16.

          #编码
          string=base64.b16encode('xiaodeng')
          print string#7869616F64656E67

    
            s is the string to encode.  The encoded string is returned.
        
        •b32decode(s, casefold=False, map01=None)
            Decode a Base32 encoded string.

          #decode_string=base64.b32decode('PBUWC33EMVXGO===')
          #print decode_string#xiaodeng

    
        •b32encode(s)
            Encode a string using Base32.

          #string=base64.b32encode('xiaodeng')#PBUWC33EMVXGO===

            s is the string to encode.  The encoded string is returned.
        
        •b64decode(s, altchars=None)
            Decode a Base64 encoded string.

          #64位解码
          #decode_string=base64.b64decode('eGlhb2Rlbmc=')##xiaodeng

    
            s is the string to decode.  Optional altchars must be a string of at least
            length 2 (additional characters are ignored) which specifies the
            alternative alphabet used instead of the '+' and '/' characters.
            
            The decoded string is returned.  A TypeError is raised if s were
            incorrectly padded or if there are non-alphabet characters present in the
            string.
        
        •b64encode(s, altchars=None)
            Encode a string using Base64.

          #64位编码
          #string=base64.b64encode('xiaodeng')#eGlhb2Rlbmc=

            s is the string to encode.  Optional altchars must be a string of at least
            length 2 (additional characters are ignored) which specifies an
            alternative alphabet for the '+' and '/' characters.  This allows an
            application to e.g. generate url or filesystem safe Base64 strings.
            
            The encoded string is returned.
        
      •decode(input, output) 
         Decode a file.#解码一个文件

       •encode(input, output)
          Encode a file.#编码一个文件

    
        •decodestring(s)#用来解码字符串
            Decode a string.

          #>>> base64.decodestring('xiaodeng')
          #'xc6&xa8uxe9xe0'

    
        •encodestring(s)#用来编码字符串  

          #>>> base64.encodestring('xc6&xa8uxe9xe0')
          #'xiaodeng '

     
        standard_b64decode(s)
            Decode a string encoded with the standard Base64 alphabet.
            
            s is the string to decode.  The decoded string is returned.  A TypeError
            is raised if the string is incorrectly padded or if there are non-alphabet
            characters present in the string.
        
        standard_b64encode(s)
            Encode a string using the standard Base64 alphabet.
            
            s is the string to encode.  The encoded string is returned.
        
        urlsafe_b64decode(s)
            Decode a string encoded with the standard Base64 alphabet.
            
            s is the string to decode.  The decoded string is returned.  A TypeError
            is raised if the string is incorrectly padded or if there are non-alphabet
            characters present in the string.
            
            The alphabet uses '-' instead of '+' and '_' instead of '/'.
        
        urlsafe_b64encode(s)
            Encode a string using a url-safe Base64 alphabet.
            
            s is the string to encode.  The encoded string is returned.  The alphabet
            uses '-' instead of '+' and '_' instead of '/'.
  • 相关阅读:
    二分查找
    Android手机APN设置(中国移动 联通3G 电信天翼),解决不能上网的问题
    cocos2dx 3.1从零学习(三)——Touch事件(回调,反向传值)
    Groovy新手教程
    总结一下用caffe跑图片数据的研究流程
    JAVA数组的定义及用法
    开机黑屏 仅仅显示鼠标 电脑黑屏 仅仅有鼠标 移动 [已成功解决]
    LeetCode——Reverse Words in a String
    oracle 库文件解决的方法 bad ELF interpreter: No such file or directory
    布局文件提示错误“No orientation specified, and the default is horizontal. This is a common so...”
  • 原文地址:https://www.cnblogs.com/dengyg200891/p/4947275.html
Copyright © 2011-2022 走看看