zoukankan      html  css  js  c++  java
  • python--基础学习(三)字符串单引号、双引号、三引号

    1、基本认识

    • 单引号字符串:'python'
    • 双引号字符串:"python"
    • 三引号字符串:'''python'''(三单引号),"""python"""(三双引号)

    2、代码示例

    #单引号
    str1='python'
    #单引号中使用双引号
    str2='"python"'
    #双引号中使用单引号
    str3="'python'"
    #三单引号
    str4='''python'''
    #三单引号中间使用双引号
    str5='''"python"'''
    #三单引号中有换行符
    str6='''hello
    python'''
    #三双引号中有换行符
    str7="""hello
    python"""
    
    print("str1: {0}".format(str1))
    print("str2: {0}".format(str2))
    print("str3: {0}".format(str3))
    print("str4: {0}".format(str4))
    print("str5: {0}".format(str5))
    print("str6: {0}".format(str6))
    print("str7: {0}".format(str6))

     

    3、运行结果:

     

    4、结果分析:

    (1)单引号中可以使用双引号,中间的会当作字符串输出

    (2)双引号中可以使用单引号,中间的会当作字符串输出

    (3)三单引号和三双引号中间的字符串在输出时保持原来的格式。

  • 相关阅读:
    golang 中 sync包的 WaitGroup
    Go_20: Golang 中 time 包的使用
    mysql 同步数据到 ElasticSearch 的方案
    mysql 对应 binlog 查看
    python3.6爬虫总结-01
    Golang 之协程详解
    golang私服搭建
    Ubuntu vim设置
    密码校验规则
    golang密码校验
  • 原文地址:https://www.cnblogs.com/lmei/p/5305146.html
Copyright © 2011-2022 走看看