Python程序:连接字符串

创新互联python教程:

写一个 Python 程序,用一个实际例子连接字符串。

连接字符串的 Python 程序示例 1

这个 Python 程序允许用户输入两个不同的字符串。接下来,我们使用算术运算符【T1+】来连接这两个字符串。

# Python Program to Concatenate Strings

str1 = input("Please Enter the First  String : ")
str2 = input("Please Enter the Second String : ")

concat1 = str1 + str2
print("The Final String After Python String Concatenation = ", concat1)

concat2 = str1 + ' ' + str2
print("The Final After String Concatenation with Space = ", concat2)

连接字符串的 Python 程序示例 2

如果要连接字符串文字,可以使用以下方法。这两种 Python 方法都意味着工作,无论有没有括号。

# Python Program to Concatenate Strings

concat1 = 'Tutorial ' 'Gateway'
print("The Final String = ", concat1)

concat2 = ('Python ' 'Programming ' 'Examples')
print("The Final String = ", concat2)

Python 字符串串联输出

The Final String =  Tutorial Gateway
The Final String =  Python Programming Examples

新闻名称:Python程序:连接字符串
本文链接:http://zjjierui.cn/article/djhcshg.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款