Golang中文显示问题

#问题描述

在使用golang的日志系统时,有时会出现一些看起来知道是什么编码但实际上解析不出来的内容:

1
\350\277\231\346\230\257\344\270\200\346\256\265\344\270\255\346\226\207

找了好久终于知道怎么读了~

#太长不看版

直接用python2print方法即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
➜  ~  python2                                               [2021/09/08 23:11] 

WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Jun 18 2021, 03:23:52)
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("\350\277\231\346\230\257\344\270\200\346\256\265\344\270\255\346\226\207")
这是一段中文
>>>

bash环境变量重载问题

#问题描述

因为会在多台机器里用我自己写的一个脚本库,如何快速的配置生效就是需要解决的问题,我的解决方法是用环境变量包。

csv乱码问题解决

#csv 乱码问题解决

csv 是比较好整理数据的语言,经常就用字符串直接拼接了,然后用 Excel 做后续处理,但是中文会乱码。

#解决方案

加一个 bom 头即可。

1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

f = open("reply.csv", "r")
data = f.read()
f.close()

f = open("reply.csv", "r", encoding="utf-8-sig")
f.write(data)
f.close()

安装Elasticsearch

#前言

博客的搜索有点难用,经常找不到东西,因为现在还是基于字符串匹配的,也没有办法进行模糊搜索,所以折腾一下,顺便学习一下Elasticsearch,记录之。