购物车小程序
#!/usr/bin/env python #-*- coding:utf-8 _*- """ @author:cjs @file: shopping.py @time: 2020/05/27 需求: 1、启动程序后,让用户输入工资,然后打印商品列表 2、允许用户根据商品编号购买商品 3、用户选择商品后,检测余额是否足够,够就直接扣款,不够就提醒 4、可随时退出,退出时,打印已购买商品和余额 字符串所有操作: #!/usr/bin/env python #-*- coding:utf-8 _*- """ @author:cjs @file: string.py @time: 2020/05/28 """ name = "my name is {name} and my age is {age} years old" print(name.capitalize()) ###首字母大写 print(name.count("e")) ###计数,有多少个"e" print(name.center(100,"-")) ###打印100个字符,不够用"-"补齐 print(name.endswith("ex")) ###以ex结尾,如果是则打印True print(name.expandtabs(tabsize=30)) ###扩展tab健 print(name.find("n")) ##