课程名称:Python3 入门教程(新版)
章节名称 第3章 Python变量和数据类型
讲师姓名:咚咚呛
课程内容:
name =new_name = name.capitalize(); name_upper = name.upper() (new_name) (name_upper) en_name =ch_name =new_en_name =en_name.lower() ch_name_casefold = ch_name.casefold(); name_swap = new_name_swap = name_swap.swapcase() (new_name_swap) name_zfill = new_name_zfill=name_zfill.zfill() (new_name_zfill) name_count=new_name_count=name_count.count() (new_name_count) (.startswith()) (.endswith()) (.find()) (.index()) (.strip()) (.strip()) (.lstrip()) (.rstrip()) (.replace(,,)) (% (,)) (.format(,)) name1 =(name1)
学习收获:
string对象的常用函数:首字母大写string.caplize,大小写 upper lower casefold,大小写翻转swapcase,
填充zfill,计数count,以开始和结尾 startswith endswith,去除字符:strip lstrip rstrip,bool集合:isspace,istitle,islower isupper,替换字母:replace(old,new,max)
格式化字符串的三种方法 %s %(a,b)string.format,f‘’,原意输出用r‘’
打卡截图: