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 '/'.
  • 相关阅读:
    【梅西加油!】梅西加油!!加油梅西!!
    [CQOI2014][bzoj3507] 通配符匹配 [字符串hash+dp]
    [NOI2011][bzoj2434] 阿狸的打字机 [AC自动机+dfs序+fail树+树状数组]
    [USACO12Jan][luogu3041] Video Game Combos [AC自动机+dp]
    [HNOI2004][bzoj1212] L语言 [Trie+dp]
    [POI2005][luogu3462] SZA-Template [fail树]
    [HNOI2008][bzoj1009] GT考试 [KMP+矩阵快速幂]
    [SDOI2008][luogu2463] Sandy的卡片 [kmp]
    [POI2006][luogu3435] OKR-Periods of Words [kmp+next数组]
    [NOI2014][bzoj3670] 动物园 [kmp+next数组应用]
  • 原文地址:https://www.cnblogs.com/dengyg200891/p/4947275.html
Copyright © 2011-2022 走看看