python concat
时间: 2023-09-10 08:10:50 浏览: 33
"Concat" is short for concatenation, which refers to the process of combining two or more strings (text values) into one. In Python, the concatenation operator is the plus sign (+). Here are some examples of concatenating strings in Python:
```
# Concatenating two strings
string1 = "Hello"
string2 = "world"
result = string1 + string2
print(result) # Output: "Helloworld"
# Concatenating a string with a number
age = 25
result = "I am " + str(age) + " years old"
print(result) # Output: "I am 25 years old"
# Concatenating multiple strings
first_name = "John"
last_name = "Doe"
city = "New York"
result = first_name + " " + last_name + " lives in " + city
print(result) # Output: "John Doe lives in New York"
```