1.打印字符串

>>> print ("hello world")
hello world

2.使用“/"进行符号转义

>>> print ("hello"world")
File "<stdin>", line 1
print ("hello"world")
^
SyntaxError: invalid syntax
加“\”符号进行转义
>>> print ("hello\"world")

3.通过“+”号将字符串连接起来

>>> print ("hello"+" "+"world")
hello world

4.字符串还可以使用乘号

>>> print ("hello"*3)
hellohellohello

5.字符串变量

name="Jasper"
print("我的名字叫",name)
print("%s是我的名字"%name)
#变量在结尾直接用逗号隔开,变量在前面或者中间任意位置需要加字符串

python学习之认识字符串的更多相关文章

  1. Python学习-第二天-字符串和常用数据结构

    Python学习-第二天-字符串和常用数据结构 字符串的基本操作 def main(): str1 = 'hello, world!' # 通过len函数计算字符串的长度 print(len(str1 ...

  2. Python学习2——使用字符串(完整版)

    """ 在C语言入门的时候字符串没有好好学习,导致后期语言根本没有入门, 更导致之后大量的codeing时间浪费,效率低下. 因此,借助这次Python入门,好好地将字符 ...

  3. python学习笔记(字符串操作、字典操作、三级菜单实例)

    字符串操作 name = "alex" print(name.capitalize()) #首字母大写 name = "my name is alex" pri ...

  4. Python学习笔记3—字符串

    原始字符串 使用\转义或者r,这种方法在网站设置网站目录结构的时候非常管用. >>> dos="c:\news" >>> print dos c ...

  5. 【Python学习笔记】字符串操作

    字符串的表示 python中的字符串是一个常量,可以使用单引号'',双引号""或三引号""" """来创建一个字符串常量 ...

  6. python学习之初识字符串

    刚接触一门语言时,字符串是很容易遇到的, 例如要从读入或者写出, 字符串与数字间的转换等. 由于字符串, 列表和元组等类型具有一定的共性(由对象组成的序列,如字符串是字符序列), 在Python中统称 ...

  7. Python学习笔记(3)-字符串

    创建字符串 一对单引号或双引号 >>> 'hello world' 'hello world' >>> "hello world" 'hello ...

  8. Python学习杂记_3_字符串操作的常用方法

    字符串操作 字符串是可以通过下标来进行取值的,但是由于字符串是不可变变量,不能通过下标来修改它的值(形式如 字符串[下标]),下标从0开始,最大下标值是字符串长度减1,即len(string)-1 P ...

  9. Python学习笔记:字符串

    字符串 字符串定义:字符串可以使用一对单引号.双引号或三引号来定义,即便是单个字符也会当做字符串来处理(Python中没有字符类型,单个字符也就是只有一个字符的字符串而已). 原始字符串:字符串中反斜 ...

  10. Python学习 Day 3 字符串 编码 list tuple 循环 dict set

    字符串和编码 字符 ASCII Unicode UTF-8 A 1000001 00000000 01000001 1000001 中 x 01001110 00101101 11100100 101 ...

随机推荐

  1. 2016HUAS暑假集训训练2 K - Hero

    题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/K 这也是一道贪心题,刚开始写时以为只要对每一敌人的攻击和血的乘积进行从小到大排序即 ...

  2. java 正则表达式获取匹配和非获取匹配

    package test1; import java.util.regex.Matcher; import java.util.regex.Pattern; public class TestExp ...

  3. CVTRES : fatal error CVT1100 , fatal error LNK1123:

    CVTRES : fatal error CVT1100: duplicate resource. type:DIALOG, name:901, language:0x0804LINK : fatal ...

  4. jquery 取消绑定事件

    $(".TreeView1_0").unbind("mouseover"); $("#id").attr("onclick&quo ...

  5. xx.substring(x,x)和xx.index()

    [转的]用一个例子解释: ip = "126.168.1.1"; i = ip.indexOf('.');                           这里默认从0开始找到 ...

  6. linq查询结果datetime类型转string类型

    var list = new SupplierLogic().GetSupplier(pageSize, pageIndex).Select(q => new { SupplierID = q. ...

  7. Nest查询示例

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. Requirejs之AMD规范

    一.什么是AMD规范 AMD是Asynchronous Module Definition-----异步模块定义 AMD规范定义了2个函数define()与require() 下面我们来看一下定义方法 ...

  9. php连接和操作mysql数据库

    <?php //数据库连接文件:link.php $link = mysql_connect("localhost", "root", "&qu ...

  10. NRF905 无线模块实验

    ---恢复内容开始--- 采用2440开发板,CON4 不仅包含了很多富余的 GPIO 引脚,还包含了一些其他 CPU 引脚, 如 AD0-AIN3, CLKOUT 等.你所看到的图中的 SPI 接口 ...