精通Python自然语言处理pdf免费下载
×Ö½Ú´®bytes
×Ö½Ú´®Ò²½Ð×Ö½ÚÐòÁУ¬ÊDz»¿É±äµÄÐòÁУ¬´æ´¢ÒÔ×Ö½ÚΪµ¥Î»µÄÊý¾Ý
×Ö½Ú´®±íʾ·½·¨£º
b"ABCD" b"\x41\x42" ...
×Ö½Ú´®µÄ¹¹Ô캯Êý£º
bytes() ´´½¨Ò»¸ö¿ÕµÄ×Ö½Ú´® £¬Í¬b¡±¡±
bytes(ÕûÊý¿Éµü´ú¶ÔÏó) Óÿɵü´ú¶ÔÏó´´½¨Ò»¸ö×Ö½Ú´®
bytes(ÕûÊýn) Éú³Én¸öֵΪ0µÄ×Ö½Ú´®
bytes(×Ö·û´®£¬encoding='utf-8') תÂë
×Ö½Ú´®µÄÔËË㣺ͬÆäËûÐòÁеÄÔËËã
+¡¢+=¡¢*¡¢*= <¡¢<=¡¢>¡¢>=¡¢!=¡¢== in / not in ÇÐƬºÍË÷Òý º¯Êý£º len max min sum any all
bytes ºÍ str Ö®¼äµÄת»»£º
str ¡ª¨C> bytes ʹÓÃencode
¾Ù¸öÀõ×Ó£º
>>> s = 'ÄãºÃ£¬ÊÀ½ç£¡' >>> s.encode(encoding='utf-8') b'\xe4\xbd\xa0\xe5\xa5\xbd\xef\xbc\x8c\xe4\xb8\x96\xe7\x95\x8c\xef\xbc\x81'
bytes¡ª->str£ºÊ¹ÓÃdecode
¾Ù¸öÀõ×Ó£º
>>> s = b'\xe4\xbd\xa0\xe5\xa5\xbd\xef\xbc\x8c\xe4\xb8\x96\xe7\x95\x8c\xef\xbc\x81' >>> s.decode(encoding='utf-8') 'ÄãºÃ£¬ÊÀ½ç£¡'
bytearrayºÍbytesÏàͬ£¬²»½²ÁË
±¾½ÚÍ꣡
ÒÔÉÏÕâƪPython3Ö®×Ö½Ú´®bytesÓë×Ö½ÚÊý×ébytearrayµÄʹÓÃÏê½â¾ÍÊÇС±à·ÖÏí¸ø´ó¼ÒµÄÈ«²¿ÄÚÈÝÁË£¬Ï£ÍûÄܸø´ó¼ÒÒ»¸ö²Î¿¼£¬Ò²Ï£Íû´ó¼Ò¶à¶àÖ§³Ö½Å±¾Ö®¼Ò¡£