textarea is empty

‎متد‎encode()‎ پايتون

Previous >    <Next  

‎متد‎encode()‎‎ رشته اي را با مجموعه كراكتري مشخص شده رمزگذاري ميكند .اگر ‎مجموعه مشخص نشده باشد پيش فرض آنUTF-‎8 ميباشد .

‎مثال ـ رمز گذاري رشته باUTF-‎8

--(go to editor for change code and run)

‎فرمت استفاده ـSyntax

string.encode(encodeing=encoding,errors=errors)

‎مقادير پارامتر ـParameter Values

Parameter Description
encoding Optional. A String specifying the encoding to use. Default is UTF-8
errors Optional. A String specifying the error method. Legal values are:
'backslashreplace' - uses a backslash instead of the character that could not be encoded
'ignore' - ignores the characters that cannot be encoded
'namereplace' - replaces the character with a text explaining the character
'strict' - Default, raises an error on failure
'replace' - replaces the character with a questionmark
'xmlcharrefreplace' - replaces the character with an xml character

‎مثال ـ در اين نمونه هاي مثال از رمزگذاريascii وكاركتري استفاده ميكنند كه نميتواند ‎رمزگذاري شود ونتيجه را با خطاهاي مختلف نشان ميدهد.

--(go to editor for change code and run)


Previous >    <Next