Reply to " Resources " to get Python learning materials
Hello everyone, I'm Pippi.
I. Introduction
A few days ago in the Python exchange Baiyin group [Mortals are not annoying], I asked a question to Python
deal with, as shown in the figure below.

Second, the realization process
Here [Mr. Yu Liang] gave an idea and code, which encodes the object into a string, and json.dumps()
converts the sum in and into the type in the process. Therefore, the parentheses of the tuple are converted to the square brackets of the array.python
Json
python
list
tuple
json
array
f-string
Use the write file directly , and when you read it below eval
, it will be restored to python
the list
type in .
draw_data = [{"tm": 275, "ab": [(753, 747), (755, 749)], "a": "0.607514", "b": "0.425784", "lW": 2, "cr": "#1795ff", "pg": 27},
{"tm": 281, "ab": [(713, 755)], "a": "0.574740", "b": "0.430732", "lW": 2, "cr": "#ee4844", "pg": 27}]
with open(f'draw.json', 'w') as f1:
f1.write(f'{draw_data}')
with open(f'draw.json', 'r') as f2:
data = eval(f2.read())
print(type(data))
print(data)
The running result is shown in the following figure:

Solve the fans' problems smoothly!
3. Summary
Hello everyone, I'm Pippi. This article mainly takes stock of a Python
string processing problem. The article gives specific analysis and code implementation for this problem, helping fans to solve the problem smoothly.
Finally, I would like to thank the fans [Mortals are not annoying] for asking questions, [Mr. Yu Liang] and [Luna] for their ideas and code analysis, and [dcpeng], [Feng Cheng], [such creatures], and [Cat Pharmacist Kelly] Participate in learning exchanges.
If you encounter any problems during the learning process, please feel free to contact me to solve them (my WeChat: pdcfighting). At the request of fans, I have created some high-quality Python
paid learning exchange groups. Welcome everyone to join my Python
learning exchange group!

--- -- --- --- --- -- --- End --- -- --- -- --- --- -- -
Recommended articles in the past:
Welcome everyone to like , leave a message, forward, reprint, thank you for your companionship and support
If you want to join the Python learning group, please reply in the background [ join the group ]
Thousands of waters and thousands of mountains are always love, can you click [ Watching ]