- 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.
- Implementing Modern DevOps
- PHP程序設(shè)計(慕課版)
- 假如C語言是我發(fā)明的:講給孩子聽的大師編程課
- JavaScript by Example
- GeoServer Beginner's Guide(Second Edition)
- 碼上行動:用ChatGPT學(xué)會Python編程
- C#實(shí)踐教程(第2版)
- Mastering Git
- Getting Started with Eclipse Juno
- Building Slack Bots
- jQuery技術(shù)內(nèi)幕:深入解析jQuery架構(gòu)設(shè)計與實(shí)現(xiàn)原理
- Visual Basic程序設(shè)計基礎(chǔ)
- Mastering OpenStack
- Learning Redis
- Scratch 3.0少兒積木式編程(6~10歲)