Я прошел десятки статей, и в этой ветке Stackoverflow, но я все еще так же невежественен, как и всегда. The main points I have read everywhere and why I don't understand them are:
The main points I have read everywhere and why I don't understand them are:
Byte string
string
Что я не понимаю < /th>
< /tr>
< /thead>
Это последовательность байтов < /td>
Это последовательность символов Unicode < /td>
все в память и диск. Чем это отличается? Поскольку символы Unicode сами являются байтами < /td>
< /tr>
используется для обработки двоичных данных < /td>
используется для обработки текстовой даты < /td>
даже не понимает, что это значит < /td>
< /tr>
readable
Human readable
Not sure what this is, even the 1's and 0's are human readable
Demonstrating that both types of data are identically stored
s = "Hello"
b = b"Hello"
with open("str.txt", "w") as f:
f.write(s)
with open("bytes.txt", "wb") as f:
f.write(b)
< /code>
a hexdump показывает, что он правда < /p>
C:\Users\OM>hexdump.exe bytes.txt
000000 48 65 6c 6c 6f
< /code>
C:\Users\OM>hexdump str.txt
000000 48 65 6c 6c 6f
< /code>
Further, After a little talk with ChatGPT, I was able to get it to say that "The only difference in both types is that strings, unlike bytes, store metadata for its characters. But the metadata is stored only in memory. And after a system reboot, the stored string and byte string has no difference at all."
I assume its hallucinating but if its true, then I dont see any reason whatsoever why the existence of both data types doesn't make each other useless and obsolete.
Подробнее здесь: https://stackoverflow.com/questions/797 ... -in-python
Какова разница между байтовой строкой и обычной строкой в Python? [дублировать] ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Разница между кодом, созданным с использованием функции шаблона, и обычной функцией
Anonymous » » в форуме C++ - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-