In this article, can strings in Python 3 be changed? can strings in Python 3 be changed?
The string has changed this method: replace, for example:
A = 'lkjhgfdsa 'A. replace ('L', '000000') '123kjhgfdsa '# return results
From the above example, we can see that str can also be changed. But !!!
This change does not really change the original string, but is equivalent to creating a new string:
>>> A = 'lkjhgfdsa '>>> B = a. replace ('L', '000000') >>> a 'lkjhgfdsa' >>> B '123kjhgfdsa'
As shown in the preceding example, the value of a is not changed. We copy the modified string to B. We can see that a and B are completely different.
Summary: strings in Python 3 cannot be changed. if The str. replace method is used to change the string, the original string remains unchanged and a new string is created after the change.
Can the strings in Python3 be changed? for more articles, refer to PHP!