zoukankan      html  css  js  c++  java
  • 【Python基础编程012 ● Python入门 ● 字符串与整数的运算 】


     ---------Python基础编程---------

    Author : AI菌


    【内容讲解】

    # 字符串与整数不能相加
    # "hello" + 10  # TypeError: must be str, not int
    
    # 把字符串复制n次,就是连续拼接n次
    print("hello" * 3)  # hellohellohello
    
    # 两个字符串可以相加 , 这里的 + 是字符串连接符的意思,用来连接两个字符串的
    print("hello" + "python")  # hellopython
    print("hello" + "python" + "ai")  # hellopythonai
    
    # 布尔类型的值可以与数字直接运算, True作为1,False作为0
    print(True + 1)  # 2
    print(False + 1)  # 1

    【代码演示】

    # 字符串与整数不能相加
    # "hello" + 10  # TypeError: must be str, not int
    
    # 把字符串复制n次,就是连续拼接n次
    print("hello" * 3)  # hellohellohello
    
    # 两个字符串可以相加 , 这里的 + 是字符串连接符的意思,用来连接两个字符串的
    print("hello" + "python")  # hellopython
    print("hello" + "python" + "ai")  # hellopythonai
    
    # 布尔类型的值可以与数字直接运算, True作为1,False作为0
    print(True + 1)  # 2
    print(False + 1)  # 1

    【往期精彩】

    ▷【Python基础编程196 ● 读取文件的4种方式】
    ▷【Python基础编程197 ● 读取文件的4种方式】
    ▷【Python基础编程198 ● 读取文件的4种方式】
    ▷【Python基础编程199 ● Python怎么读/写很大的文件】
    ▷【Python基础编程200 ● 读取文件的4种方式】
    ▷【Python基础编程201 ● 读取文件的4种方式】
    ▷【Python基础编程202 ● 读取文件的4种方式】
    ▷【Python基础编程203 ● 读取文件的4种方式】

    【加群交流】



  • 相关阅读:
    Android 面试题汇总
    Android中Listview展示及其优化好处
    手机APP创建桌面快捷方式
    popupwindow展示
    showSetPwdDialog--自定义对话框
    android 四大组件之---Service
    会话技术( Cookie ,Session)
    Request 和 Response 原理
    Servlet的生命周期+实现方式
    pull解析器: 反序列化与序列化
  • 原文地址:https://www.cnblogs.com/hezhiyao/p/13518268.html
Copyright © 2011-2022 走看看