2020年8月
argparse and struct in python
眼睛进阶处理 in Photoshop
在人像照片中,一双炯炯有神的眼睛会让照片整体突出,下面我们来尝试通过提升亮度,增加细节等过程来实现。
string <-> byte in python
To transform a unicode string to a byte string in Python do this:
>>> 'foo'.encode('utf_8')
b'foo'
To transform a byte string to a unicode string:
>>> b'foo'.decode('utf_8')
'foo'
To convert a string to bytes.
data = "" #string data = "".encode() #bytes data = b"" #bytes
To convert bytes to a String.
data = b"" #bytes data = b"".decode() #string data = str(b"") #string
hex <-> str in python
str to hex:
import codecs
hexlify = codecs.getencoder('hex')
hexlify(b'Blaah')[0]
out:
b'426c616168'
hex to str:
import codecs
decode_hex = codecs.getdecoder("hex_codec")
s = decode_hex(b'426c616168')[0]
out:
b'Blaah'