姜鹏辉的个人博客 GreyNius

【Python】一些小技巧

2020-04-02

随用随记

读取stop_words

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
stop_words = set(open(os.path.join(BASE_DIR, 'stopwords.txt'), 'r').read().split())

字符串bu前缀转换

u'V''V'u'\u0056'等价,即Unicode码,类型为string

b'\x56'b'V'等价,但只能放ASCII码,否则会报错,类型为bytes

b = str.encode('V')  # u 2 b 
a = bytes.decode(b'V') # b 2 u

下一篇 Excel公式笔记

Comments

Content