zoukankan      html  css  js  c++  java
  • 练习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.
  • 相关阅读:
    六.Linux其他命令
    五.Linux压缩文件的操作命令(压缩解压)
    sigaction
    log_note log_error log_warning
    SIGHUP
    pthread_create
    semaphore
    getpwuid
    close port
    pthread
  • 原文地址:https://www.cnblogs.com/luoxun/p/13141852.html
Copyright © 2011-2022 走看看