Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

python - How to cast string to byte like object

I am trying to make a python script that encodes any file into a txt file. So far I can encode an input file into a txt file that contains the original files name, content and a sha hash for integrity checking (if you wish I can dump the code so far here). Currently, I just make a standard list and dump said list into a txt file. However, when reading from the list I get strings, but have no way of casting the string into a "byte like object", and a Google search only shows conversion (cast and convert are different) methods. Is there any way to cast the string in the way you can do str(variable)?

Also, on a side note: does "rb" include metadata, title, etc?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...