2018年1月11日 星期四

Python: Prove that two string variables of same value point same memory location

Python: Prove that two string variables of same value point same memory location

Python Basic: Exercise-117 with Solution

Write a Python program to prove that two string variables of same value point same memory location.
Sample Solution:-

str1 = "Python"
str2 = "Python"

print("\nMemory location of str1 =", hex(id(str1)))
print("Memory location of str2 =", hex(id(str2)))
print()

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

Memory location of str1 = 0x700560
Memory location of str2 = 0x700560

>>> 

沒有留言:

張貼留言

MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構

MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 這張圖片展示了一個 結合 MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 (主要透過 Node-RED 進行資料整合)。 系統包含三個核心部分,其運作功能說明如下: 1. ESP32 終端設備(硬體控制層...