represents 16 binary number 11; Represented by a 0x prefix, the eg:0x23 represents a 16 binary number of 23.5.bytes typeIn Python3, text is always Unicode, represented by the STR type, and binary data (audio, video) is represented by the bytes type.(in Python3, the data transmission with the socket must be transmitted in binary form, so the STR type is converted to the bytes type)Msg= "I'm learning Python3."Print (msg)Print (Msg.encode (encoding= ' utf-8 '))Print (Msg.encode (' Utf-8 '). Deco
In practice, there is a big problem, in JavaScript, there may be some Chinese strings, we want to be binary stream encoding, we need to convert it to UTF8 encoding.In other words, the input is a string: ‘呆滞的慢板今天挣了100块钱‘ .The output is a sequence of bytes:[229,145,134,230,187,158,231,154,132,230,133, 162, 230, 157, 191, 228, 187, 138, 229, 164, 169, 230, 140, 163, 228, 186, 134, 49, 48, 48, 229, 157, 151, 233, 146, 177] Or is this a single-byte string:"\xe5\
, the internal automatically shuts down and frees the file resource.After Python 2.7, with also supports the management of multiple file contexts simultaneously, namely:with open("wenjian","r",encoding="utf-8") as f, open("wenjian2","r",encoding="utf-8") as f2: print(f2.readline())Character encoding ConversionPython 3 The most important new feature is probably a clearer distinction between text and binary data, and no longer automatically decodes bytes byte strings. Text is always Unic
'= urlparse.urlparse (URL)print(Result)Get result first using the Urlparse.urlparse (URL) methodParseresult (scheme='https', netloc='www.baidu.com', path= ' / S ', params=', query='Ie=utf-8f=8rsv_bp=0rsv_idx=1tn=baidu wd=python%20%e5%8f%91%e9%80%81%e9%82%ae%e4%bb%b6rsv_pq=8ddee8730003c015rsv_t=fc02p4%2by% 2fpkzafftaqgcglcxpvpvojkm6zg7pgczzb%2fezaqkxhsuwrpphqsrqlang=cnrsv_enter=1rsv_sug3=14rsv_ sug1=10rsv_sug7=101', fragment=')Extract from query parameter in resultImport Urllib Import 'https://w
mysql->charset.
Mysql_real_string in judging the character of wide character set, according to this member variable to use different strategies, such as if it is utf-8, then will use LIBMYSQL/CTYPE-UTF8.C.
To see an instance, the default MySQL connection character set is Latin-1, (Classic 5c problem):
Copy Code code as follows:
$db = mysql_connect (' localhost:3737 ', ' root ', ' 123456 ');
mysql_select_db ("test");
$a = "\x91\x5c
mysql_escape_string is that it takes into account the "current" character set. So where does this current character set come from?
By the way, you guessed right, that's mysql->charset.
Mysql_real_string in judging the character of wide character set, according to this member variable to use different strategies, such as if it is utf-8, then will use LIBMYSQL/CTYPE-UTF8.C.
To see an instance, the default MySQL connection character set is Latin-1, (Classic 5c problem):
Copy Code code as fo
tables;+-----------------+| Tables_in_test1 |+-----------------+| Address | | Authors | | Book_m2m_author | | Books | | Customer | | Student | | Study_record |+-----------------+7 rows in Set (0.00 sec) mysql> insert into books (name) value (' I '); Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near '; ' in line 1mysql> ins ert into books (name) value (' I '); ERROR 1366 (HY000): Incorrect string value
In the Redis store Chinese, reading will appear garbled (in fact, not garbled, but not our saved Chinese display)
1 redis> set Test "US"
2 OK
3 redis> get test
4 "\xe6\x88\x91\xe4\xbb\xac"
How to get it in Chinese when it's taken. You just need to add--raw behind the REDIS-CLI.
redis> get Test
"US"At this point if still garbled as shown below
This is due to a problem caused by the Command Line window encoding. You can modify the command
\x91\n\xe5\x9b\xbe\xe7\x89\x87\n\xe6\x96\x87\xe6\xa1\xa3\n\xe4 \xb8\x8b\xe8\xbd\xbd\n\xe9\x9f\xb3\xe4\xb9\x90\n\xe6\xa1\x8c\xe9\x9d\xa2\n' Output If you log in with a normal user #-*-coding:utf-8-*-
#blog:http://www.cnblogs.com/linux-chenyang/
ImportParamiko#To create an SSH objectSSH =Paramiko. Sshclient ()#allow connections to hosts that are not in the Know_hosts file
Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ())#connecting to a serve
Label:Get user nickname nickname with emoji expression, converted to character code is this form "\xf0\x9f\x91\x8d\xe6\x94 ...", The following error may occur with direct save caused By:java.sql.SQLException:Incorrect string value: ' \xf0\x9f\x98\x84 ' forColumn ' Review ' at row 1At com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:1074) at Com.mysql.jdbc.MysqlIO.checkErrorPacket (Mysqlio.java:4096) at Com.mysql.jdbc.MysqlIO.checkErrorPacket
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.