- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 79字
- 2021-07-02 14:00:22
Strings are immutable
Strings are immutable, meaning we can't change the values. Refer to the given example:
>>> welcome = 'Hello, John!'
>>> welcome[0] = 'Y'
TypeError: 'str' object does not support item assignment
As the strings are immutable; we cannot change an existing string. But we can create a new string that will be different from the original:
>>> str1 = 'Hello John'
>>> new_str = 'Welcome' + str1[5:]
>>> print(str1)
Hello John
>>> print(new_str)
Welcome John
>>>
推薦閱讀
- The Complete Rust Programming Reference Guide
- 流量的秘密:Google Analytics網站分析與優化技巧(第2版)
- WildFly:New Features
- Gradle for Android
- Android開發案例教程與項目實戰(在線實驗+在線自測)
- Getting Started with LLVM Core Libraries
- Mastering openFrameworks:Creative Coding Demystified
- Unity 2018 Shaders and Effects Cookbook
- Visual Studio 2015高級編程(第6版)
- Odoo 10 Implementation Cookbook
- 深度探索Go語言:對象模型與runtime的原理特性及應用
- Julia數據科學應用
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)
- Machine Learning for OpenCV
- Python一行流:像專家一樣寫代碼