• 练习6--字符串和文本


    1 字符串定义补充:指的是一些你想要让你的程序呈现给别人或者”输出“出来的文本信息

    2 格式字符串:f-String

    3 .format()语法:本程序貌似使用了一个对象传入?我也没有特别搞明白

    4 代码:

    types_of_people = 10
    x = f"There are {types_of_people} types of people."
    binary = "binary"
    do_not = "don't"
    y = f"Those who know {binary} and those who {do_not}."
    print(x)
    print(y)
    print(f"I said:{x}")
    print(f"I also said:'{y}'")
    hilarious = False
    joke_evaluation = "Isn't that joke so funny?!{}"
    print(joke_evaluation.format(hilarious))
    w = "This is the left side of..."
    e = "a string with a right side."
    print(w+e)

    5 执行结果

    PS C:Usersguohongzhen> cd E:3_work4_python2_code2_LearnPythonTheHardWay
    PS E:3_work4_python2_code2_LearnPythonTheHardWay> python ex6.py
    There are 10 types of people.
    Those who know binary and those who don't.
    I said:There are 10 types of people.
    I also said:'Those who know binary and those who don't.'
    Isn't that joke so funny?!False
    This is the left side of...a string with a right side.
  • 相关阅读:
    批处理学习总结之常用命令1
    Delphi常用数据类型
    Delphi预编译指令总结
    Delphi同步互斥总结
    MyEclipse 环境配置总结
    倒排索引
    laravel 学习相关笔记
    elasticsearch倒排索引原理
    原生sql和 TP sql怎么关联?
    elastic
  • 原文地址:https://www.cnblogs.com/luoxun/p/13141852.html
Copyright © 2020-2023  润新知