Is python string a variable type?

anonymity
Release: 2019-06-14 09:54:15
Original
11363 people have browsed it

All the following content is based on memory address

Immutable data type: When the value of the corresponding variable of this data type changes, then its corresponding memory address will also change. This data type is called an immutable data type.

Variable data type: When the value of the corresponding variable of this data type changes, then its corresponding memory address does not change. This data type is called a variable data type.

Is python string a variable type?

Summary: The address changes after the immutable data type is changed, but the address does not change when the variable data type is changed

String

b = 'djx'
print(id(b),type(b))
b = 'djx1996'
print(id(b),type(b))
535056476344 <class &#39;str&#39;>
535056476624 <class &#39;str&#39;>
Copy after login

We can find that when the data changes, the memory address of the variable changes, then the string is an immutable data type.

The above is the detailed content of Is python string a variable type?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template