- 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
>>>
推薦閱讀
- iOS 9 Game Development Essentials
- Java程序設計與計算思維
- JavaScript前端開發與實例教程(微課視頻版)
- HTML5游戲開發案例教程
- Podman實戰
- 深入淺出DPDK
- 編譯系統透視:圖解編譯原理
- BIM概論及Revit精講
- Visual C++開發入行真功夫
- C和C++游戲趣味編程
- Python全棧數據工程師養成攻略(視頻講解版)
- 從零開始學Android開發
- Visual Basic程序設計全程指南
- Microsoft Exchange Server 2016 PowerShell Cookbook(Fourth Edition)
- Oracle Database XE 11gR2 Jump Start Guide