09-08-周一_15-39-37

This commit is contained in:
2025-09-08 15:39:37 +08:00
parent b21b9a72f3
commit 399e7d78e6
2 changed files with 49 additions and 13 deletions

View File

@@ -23,7 +23,7 @@ f.close()
```python
f.close()
# 回收操作系统级打开的文件,系统级别不回收会导致文件一直被占用,如果程序以外崩溃,会导致
# 回收操作系统级打开的文件,系统级别不回收会导致文件一直被占用,如果程序以外崩溃,会导致数据丢失
del f
# 回收应用程序级的变量
```
@@ -276,28 +276,16 @@ os.rename('a.txt.new','a.txt')
文件a.txt内容每一行内容分别为商品名字价钱个数。
apple 10 3
tesla 100000 1
mac 3000 2
lenovo 30000 3
chicken 10 3
通过代码,将其构建成这种数据类型:[{'name':'apple','price':10,'amount':3},{'name':'tesla','price':1000000,'amount':1}......] 并计算出总价钱。