摘要: list(vocab.token_to_idx.items()) 先用items函数转换为键值对dict_items([('<unk>', 0),xxx对象,再用list转为list。 阅读全文
posted @ 2021-08-23 17:10 zae 阅读(577) 评论(0) 推荐(0) 编辑
摘要: runoob re.sub例子 re.sub(pattern, repl, string, count=0, flags=0) re.sub('[^A-Za-z]+', ' ', line).strip().lower() 匹配多个连续的非字母,将它们替换为空格。 连续多个+ 非^ 单个[] 字母A 阅读全文
posted @ 2021-08-23 16:45 zae 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 加入f之后,可以直接在字符串中填入需要替换的字符: print('# text lines: {len(lines)}') print(f'# text lines: {len(lines)}') output: # text lines: {len(lines)} # text lines: 32 阅读全文
posted @ 2021-08-23 16:36 zae 阅读(638) 评论(0) 推荐(0) 编辑