1. File a.txt content: Each line content is the product name, the price, the number.
Apple 10 3
Tesla 100000 1
MAC 3000 2
Lenovo 30000 3
Chicken 10 3
By code, build it into this data type: [{' name ': ' Apple ', ' price ': ' Amount ': ' 3},{' name ': ' Tesla ', ' price ': 1000000, ' Amount ': 1} ...] and calculate the total price.
2, there are the following documents:
-------
Alex is the old boy Python initiator, creator.
Alex is actually a tranny.
Who says Alex is SB?
You guys are so funny, Alex, you can't hide the temperament of senior cock silk.
----------
Replace all Alex in the file with an uppercase SB.
3. File A1.txt content: Each line content is the product name, the price, the number.
File contents:
Name:apple price:10 Amount:3 year:2012
Name:tesla price:100000 amount:1 year:2013
Through the code, build it into this type of data:
[{' name ': ' Apple ', ' price ': Ten, ' Amount ': 3},
{' name ': ' Tesla ', ' price ': 1000000, ' Amount ': 1} ...]
and calculate the total price.
4, File A2.txt content: Each line content is the product name, the price, the number.
File contents:
Number of department number average age remark
1 Python 30 26 single Dog
2 Linux 26 30 no objects
3 Operations Department 20 24 more girls
Through the code, build it into this type of data:
[{' Ordinal ': ' 1 ', ' Department ':P Ython, ' number ': 30, ' mean age ': 26, ' remark ': ' Single Dog '},
......]
and calculate the total price.
Python Basic Learning 11 days, homework questions