随笔分类 - python
摘要:import numpy as np q_f = open('weight','rb') weight = np.fromfile(q_f, dtype=np.int16) weight = np.reshape(weight,(512,512)).T weight = weight.flatten
阅读全文
摘要:import argparse def main(): parser = argparse.ArgumentParser(description="Demo of argparse") parser.add_argument('-n', dest='name', default='Li') pars
阅读全文
摘要:正则表达式去除中文字之间的空格,保留英文单词之间的空格,对于英文单词中间夹杂着数字的情况,应该保留空格但没有保留 # -*- coding:utf-8 -*- # import re def _clean_space(text): match_regex = re.compile(u'[\u4e
阅读全文
摘要:python不同语言的字符串连接成文本 # -*- coding:utf-8 -*- # import sys import unicodedata import six _ALPHANUMERIC_CHAR_SET = set( six.unichr(i) for i in xrange(sys.
阅读全文
摘要:这个方法输出结果是正确的 def is_Chinese(text): zhPattern = re.compile(u'[\u4e00-\u9fa5]+') for ch in text: match = zhPattern.search(ch) if(match): return True ret
阅读全文
摘要:1 str = "Wie geht's dir für" 2 print(str) 3 str2 = str.encode(encoding='UTF-8') 4 print(str2) 5 str3 = str2.decode(encoding='UTF-8') 6 print(str3) 7 8
阅读全文

浙公网安备 33010602011771号