python
tonystank3000
这个作者很懒,什么都没留下…
展开
-
查看字符的所占字节数
查看字符的所占字节数比如你要查看的字符是个???? emoji的字符In [12]: a="""????"""In [13]: a.encode('utf8')Out[13]: b'\xf0\x9f\x98\x8b'In [14]: b=a.encode('utf8')In [15]: len(b)Out[15]: 4????编码为utf8之后,所以占4个字节,要使用utf8mb4...原创 2021-05-08 16:21:44 · 3052 阅读 · 0 评论 -
pyenv、venv、virtualenv三种python虚拟环境的区别
venvpython3.3版本之后自带的虚拟环境,无需额外安装python3 -m venv ./venvvirtualenv需要安装后使用,好处是能支持python2和python3pip install virtualenvpyenv需要安装的可以访问这里,https://github.com/pyenv/pyenv。好处是可以在pyenv里安装不同版本的python,然后再根据不同版本的python创建不同的虚拟环境。非常强大。...原创 2021-03-26 15:25:39 · 549 阅读 · 0 评论 -
python的xlwt库写入报错Exception: String longer than 32767 characters
使用python的xlwt库写入xls的时候,报错Exception: String longer than 32767 characters解决办法:使用xlsxwriter库,这个库是将数据截断,但是不会报错import xlsxwriterdef write_excel_xls(path, sheet_name, value): index = len(value) workbook = xlsxwriter.Workbook(path) sheet = wor原创 2020-12-24 16:43:42 · 3569 阅读 · 1 评论