jackfrued / jackfrued/Python-100-Days
Day14中编码问题
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
想请教下Day14中TCP套接字传输图片文件例子中,这句代码:
data = b64encode(f.read()).decode('utf-8')
为何这么写。如果是json文件不能传输二进制数据,则直接b64编码不就可以了吗?然后我这样试出现错误:bytes类型的不能dumps。求解答,而且如果二进制通过b64编码,即是一串字符串了,为何还能通过utf-8进行解码,utf-8解码不是将二进制01串解码成字符串吗?
希望热心网友耐心解答,不胜感激
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Day14 TCP socket image-transfer example and inspect the line data = b64encode(f.read()).decode('utf-8'). Reproduce the reported error when attempting to serialize a bytes value in JSON. Done when the example or its documentation clearly explains the data representation and encoding steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100