- Hands-On Penetration Testing with Python
- Furqan Khan
- 218字
- 2021-07-02 14:13:48
String concatenation and replication
+ is the concatenation operator that's used in Python to concatenate two strings. As always, the result of the concatenation is a new string and unless we get the updated string, the update will not be reflected with the original string object. The + operator is internally overloaded to perform concatenation of objects when it is used on string types. It is also used for the addition of two numbers when used on numeric data types, like so:

Interestingly, Python also supports another operator that gets overloaded when used with string data types. Instead of performing a conventional operation, this operator performs a variation of the original operation so that the functionality can be replicated across string data types. Here, we are talking about the multiplication operator, *. This is conventionally supposed to perform the multiplication of numeric data types, but when it is used on string data types, it performs a replication operation instead. This is shown in the following code snippet:

In the preceding case, the multiplication operator actually replicates the Hello world string stored in the c variable five times, as we specified in the expression. This is a very handy operation and can be used to generate fuzzing payloads, which we will see in the later chapters of this book.
- DevOps:軟件架構師行動指南
- Learn Blockchain Programming with JavaScript
- 深度學習經典案例解析:基于MATLAB
- Oracle Database In-Memory(架構與實踐)
- 算法大爆炸:面試通關步步為營
- DevOps Automation Cookbook
- MySQL數據庫管理與開發(慕課版)
- Windows內核編程
- 低代碼平臺開發實踐:基于React
- Scratch·愛編程的藝術家
- Mastering Concurrency Programming with Java 9(Second Edition)
- The Statistics and Calculus with Python Workshop
- 跟小樓老師學用Axure RP 9:玩轉產品原型設計
- INSTANT EaselJS Starter
- VC++ 2008專題應用程序開發實例精講