回覆列表
  • 1 # 坡這裡奎特

    Python encode() 方法以 encoding 指定的編碼格式編碼字串。errors引數可以指定不同的錯誤處理方案。語法encode()方法語法:str.encode(encoding="UTF-8",errors="strict")引數encoding -- 要使用的編碼,如"UTF-8"。errors -- 設定不同錯誤的處理方案。預設為 "strict",意為編碼錯誤引起一個UnicodeError。 其他可能得值有 "ignore", "replace", "xmlcharrefreplace", "backslashreplace" 以及透過 codecs.register_error() 註冊的任何值。返回值該方法返回編碼後的字串。例項以下例項展示了encode()方法的例項:#!/usr/bin/pythonstr = "this is string example....wow!!!";print "Encoded String: " + str.encode("base64","strict")

  • 中秋節和大豐收的關聯?
  • 多肉植物小和錦怎麼養,如何養好小和錦?