Programming

关于\x开头的字符串编码转换中文解决方法

六二三
\x开头的编码是十六进制字符,\x后面跟的字符即为十六进制的字符串。 1In [41]: s1 = "世界如此美妙,我却如此暴躁,这样不好不好" 2In [42]: s1.encode("utf-8") 3Out[42]: b'\xe4\xb8\x96\xe7\x95\x8c\xe5\xa6\x82\xe6\xad\xa4\xe7\xbe\x8e\xe5\xa6\x99\xef\xbc\x8c\xe6\x88\x91\xe5\x8d\xb4\xe5\xa6\x82\xe6\xad\xa4\xe6\x9a\xb4\xe8\xba\x81\xef\xbc\x8c\xe8\xbf\x99\xe6\xa0\xb7\xe4\xb8\x8d\xe5\xa5\xbd\xe4\xb8\x8d\xe5\xa5\xbd' 4Out[43]: 将\x转为中文的几种方式: 1$ echo -e...

原来Bash的并行计算是这样的

六二三
今天有个批量下载图片的任务,不打算用python或者其他高级语言实现,决定用bash尝试下。 接下来我们一起了解下bash的并发任务是如何实现的?先上一版简单粗暴的代码:

Split string with multiple delimiters in Python

六二三
Python string split() method allows a string to be easily split into a list based on a delimiter. Though in some cases, you might need the separation to occur based on not just one but multiple delimiter values. This quick 101 article introduces two convenient approaches this can be achieved in Python. Split String With Two Delimiters in Python Assume the following string. 1text = "python is, an easy;language; to, learn." For our example, we need to split it either by a semicolon followed by a space ;, or by a...