Python gets host byte order

Source: Internet
Author: User

Using Python can quickly get information about the system, such as the platform, byte order, and Python's maximum recursion limit, such as:

Import sys# get byte orderprint sys.byteorder# get platform print sys.platform# Nothing to say ^_^ print Sys.getrecursionli MIT ()

The following C code validation can be used with respect to the byte order:

1#include <stdio.h>2 3typedef unsignedChar*Char_format;4 5 voidShow_byte (Char_format type,intlength) {6 7     inti;8      for(i =0; i < length; i++) {9fprintf (stdout,"%2.x", Type[i]);Ten     } Onefprintf (stdout,"\ n"); A } -  - intMainintargcChar Const*argv[]) { the  -     intnum =0x12345678; -      -fprintf (stdout,"%x:", num); +Show_byte (Char_format) &num,sizeof(num)); -  +     return 0; A}

The small end sequence is the lower weight in front, the big endian is the high weight in front.

For example, 0x12345678 is stored in small-endian order at 78 56 34 21, while the big endian is stored in 12 34 56 78.

Python gets host byte order

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.