zoukankan      html  css  js  c++  java
  • 更多关于字符串string

    1 print('Chris' + 2)
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-37-82ccfdd3d5d3> in <module>()
    ----> 1 print('Chris' + 2)
    
    TypeError: must be str, not int

    print('Chris' + str(2))
    Chris2

    字符串的格式设置 
    1
    sales_record = { 2 'price': 3.24, 3 'num_items': 4, 4 'person': 'Chris'} 5 6 sales_statement = '{} bought {} item(s) at a price of {} each for a total of {}' 7 8 print(sales_statement.format(sales_record['person'], 9 sales_record['num_items'], 10 sales_record['price'], 11 sales_record['num_items']*sales_record['price']))
    Chris bought 4 item(s) at a price of 3.24 each for a total of 12.96




     
  • 相关阅读:
    额外的 string 操作
    vector 对象是如何增长的
    顺序容器操作
    容器库概览
    顺序容器概述
    特定容器算法
    泛型算法结构
    再探迭代器
    定制操作
    使用关联容器
  • 原文地址:https://www.cnblogs.com/zhengzhe/p/8510858.html
Copyright © 2011-2022 走看看