Python on the misunderstanding of the bytes class method to digital conversion, the importance of JSON

Source: Internet
Author: User

This article originated from a mistake, found in bytes () can fill in the numbers, turned out is also bytes type, impatient to put the things inside decode out. The result is empty. Come on, think it's a command unskilled. In fact, the logic is wrong.

A1 = bytes ('one', encoding='utf-8')print  = a1.decode ()print= bytes (one)print= A2.decode () Print (B2)

Wrong logic: bytes int to byte type, then converts byte type to int by decode

650) this.width=650; "title=" image "style=" margin:0px; Background-image:none; "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/9C/C3/ Wkiol1l1vcab29geaaan33ucxky233.png "" 244 "height=" 123 "/>

int can indeed be converted to byte, but byte is not going to go back int. Unless you define a function yourself or use some of the more complex commands built in.

http://m.blog.csdn.net/crylearner/article/details/38521685

-----------------------------------------------

The basic tutorial will generally ask you to turn int into STR, then STR to byte, decode, byte to str, then Int. It's also very troublesome. Though the logic is right.

It seems that in a simple programming, STR is not around the past!

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/1102460/201702/ 1102460-20170215190515285-150928547.png "/>

Reference: http://www.cnblogs.com/zanjiahaoge666/p/6402907.html

--------------------------------------------------

Secret weapon JSON

Lenovo to more, in case I was an array to go to byte, or dictionary, and so on, it would be more complicated.

In fact, you should not forget a tool that is not complicated, that is, JSON. With JSON, you can soar all the data transformations and restores!

Not just arrays, dictionaries, even music, video files. JSON as competent

Academic or Football analysis Exchange: chinamaths (into the discussion group)
Don ' t hesitate to comment or add a like-yours Bill
Bill ' s tech blog Football Analysis Blog Football lottery Data video
Bill Geek Log _ Blog Park Bill Football Data _ NetEase Blog Football lottery tv_ Youku
Bill Geek Log _csdn Bill Football Data _ Sina Blog Football lottery tv_ Sohu Video
Bill Geek Log _51cto Bill Football Data _ Sina Weibo Football lottery Tv_ Himalaya
Bill Geek Log _ Open source China Bill Football Data _ official URL Football lottery tv_56 Video
Bill Geek Log _github Bill Football Data _ headline number Number: zucai99

Python on the misunderstanding of the bytes class method to digital conversion, the importance of JSON

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.