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&\xa8u\xe9\xe0'


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

      #>>> base64.encodestring('\xc6&\xa8u\xe9\xe0')
      #'xiaodeng\n'

 
    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 '/'.

 

posted @ 2015-11-08 14:24  Xiao|Deng  阅读(485)  评论(0编辑  收藏  举报