2018年1月9日 星期二

Python: Test whether the system is a big-endian platform or little-endian platform

Python: Test whether the system is a big-endian platform or little-endian platform

Python Basic: Exercise-77 with Solution

Write a Python program to test whether the system is a big-endian platform or little-endian platform.
Sample Solution:-
import sys
print()
print(sys.byteorder)

if sys.byteorder == "little":
    #intel, alpha
    print("Little-endian platform.")
else:
    #motorola, sparc
    print("Big-endian platform.")
print()

=========== RESTART: F:/Python_APSC/py-ex-basic-77.py =============

little
Little-endian platform.

>>> 

沒有留言:

張貼留言

WOKWI LED + MQTT Node-Red SQLite

WOKWI LED + MQTT Node-Red SQLite const char *mqtt_broker = "broker.mqtt-dashboard.com" ; const char *topic1 = "alex9ufo/e...