2022年12月20日

摘要: var counter = 3; Timer.periodic(const Duration(seconds: 1), (timer) { print(timer.tick); counter--; if (counter == 0) { print(counter); timer.cancel() 阅读全文
posted @ 2022-12-20 15:19 bobo2404 阅读(10) 评论(0) 推荐(0) 编辑

2022年12月12日

摘要: \ + 字符 \n 换行,一般用于末尾,strip对其也有效 \t 横向制表符 \v 纵向制表符(会有一个男性符号) \a 响铃 (编译器里会响) \b 退格符,将光标前移,覆盖(删除前一个) \r 回车 \f 翻页(几乎用不到,会出现一个女性符号) \' 转义字符串中的单引号 \'' 转义字符串中 阅读全文
posted @ 2022-12-12 22:27 bobo2404 阅读(48) 评论(0) 推荐(0) 编辑

2022年12月11日

摘要: 什么是格式化 定义:一个固定的字符串中有部分元素是根据变量的值而改变的字符串 今天是xx,星期xx,大家好 date = '2022.1211' day = '--' 根据类型定义的格式化 'my name is %s, my age is %s' % ('dewei', 33) #coding:u 阅读全文
posted @ 2022-12-11 22:11 bobo2404 阅读(23) 评论(0) 推荐(0) 编辑
 
摘要: 常见编码格式 # coding:ascii print('哈哈') # ?? print('haha') # haha#coding: gbk 支持英文 通用编码格式 utf-8 是一种国际通用的编码格式 阅读全文
posted @ 2022-12-11 20:49 bobo2404 阅读(24) 评论(0) 推荐(0) 编辑
 
摘要: #isspace istitle isupper islower#isspace 判断字符串是否是一个由空格组成的字符串booltype = string.isspace() -> 无参数可传,返回一个布尔类型#由空格组成的字符串,不是空字符串:!=''#istitle 判断字符串是否是一个标题类型 阅读全文
posted @ 2022-12-11 20:41 bobo2404 阅读(76) 评论(0) 推荐(0) 编辑

2022年12月10日

摘要: 用法 newstr = string.replace(old,new,max) 参数 old: 被替换的元素 new: 替代old的新元素 max: 可选,代表替换几个,默认全部替换全部匹配的old元素 #定义超长字符串 info = ('对国家的科技等客观角度的恐惧的感觉开关机' '而国家偶尔哦减 阅读全文
posted @ 2022-12-10 22:39 bobo2404 阅读(225) 评论(0) 推荐(0) 编辑
 
摘要: strip将去掉字符串左右两边的指定元素,默认是去掉空格 newstr = string.strip(item) 参数:括弧里需要传一个你想去掉的元素,可不填写 ' hello xiaomu '.strip() //hello xiaomu 'hello xiaomu'.strip('h') //e 阅读全文
posted @ 2022-12-10 21:46 bobo2404 阅读(43) 评论(0) 推荐(0) 编辑
 
摘要: string.find(item) -> item:想查询的元素,返回一个整型 string.index(item) 返回一个整型或者报错 find与index的区别 如果find找不到,会返回-1 如果index找不到元素,会导致程序报错 info = 'python is a good code 阅读全文
posted @ 2022-12-10 20:57 bobo2404 阅读(60) 评论(0) 推荐(0) 编辑

2022年11月23日

摘要: zfill为字符串定义长度,如不满足,缺少的部分用0填补 用法 newstr = string.zfill(width) width:新字符串希望的宽度 注意事项 1.与字符串的支付无关 2.如果定义长度小于当前字符串长度,则不发生变化 阅读全文
posted @ 2022-11-23 20:39 bobo2404 阅读(23) 评论(0) 推荐(0) 编辑
 
摘要: 功能:将字符串中大小写字母进行转换 newstr = string.swapcase() 注意事项:只对字符串中的字母有效 阅读全文
posted @ 2022-11-23 20:20 bobo2404 阅读(16) 评论(0) 推荐(0) 编辑