码迷,mamicode.com
首页 > 其他好文 > 详细

string 字符串

时间:2018-01-27 00:48:54      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:nbsp   pytho   class   使用   输出   pre   str   --   div   

创建字符串
var1 = "world"
var2 = "python"
var3 = """
hello world python
"""
print (var1 var2 var3)

输出结果:
world
python
hello world  python
字符串的拼接方法一
var1 = "hello"
var2 = "python"
print (var1 +" "+ var2)

输出结果:
hello python
字符串的拼接方法二
var1 = "python"
var2 = "world"
var3 = ‘‘.jion([a,b])
字符串乘法
var1 = "python " print (var1*5) 输出结果: python python python python python
字符串续行("\"续行符)
var1= """
hello worldpython
"""
print (var1)

输出结果:
hello world python
-----------------------------
不使用续行符的结果
var1= """
hello world
python
"""
print (var1)
输出结果:
hello wordl
python

 

string 字符串

标签:nbsp   pytho   class   使用   输出   pre   str   --   div   

原文地址:https://www.cnblogs.com/guog1/p/8361791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!