• 更多关于字符串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




     
  • 相关阅读:
    作业5,6 2019/10/23
    作业1、2、3、4 2019/10/23
    实现Map传参Mybatis
    maven工程配置pom.xml实现mybatis的访问数据库操作
    测试
    Postman篇之命令行测试
    unittest框架
    测试
    测试
    测试
  • 原文地址:https://www.cnblogs.com/zhengzhe/p/8510858.html
Copyright © 2020-2023  润新知