创新互联python教程:
写一个 Python 程序,用一个实际例子连接字符串。
这个 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 方法都意味着工作,无论有没有括号。
# 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://www.shufengxianlan.com/qtweb/news31/445381.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联