Python 水果统计
f = open("水果.txt", mode="r", encoding="utf-8")
lst = []
for line in f: # 1,香蕉,1.85,50
dic = {} # 每行都是一个字典
line = line.strip() # 去掉空白 \n 1,香蕉,1.85,50
a, b, c, d = line.split(",") # [1, 香蕉, 1.85, 50]
dic['id'] = a
dic['name'] = b
dic['price'] = c
dic['totle'] = d
lst.append(dic)
print(lst)
#
f = open("水果.txt", mode="r", encoding="utf-8")
line = f.readline().strip() # 第一行内容, 编号,名称,价格,数量,哈哈
h,i,j,k = line.split(",")
lst = []
for line in f: # 1,香蕉,1.85,50
dic = {} # 每行都是一个字典
line = line.strip() # 去掉空白 \n 1,香蕉,1.85,50
a, b, c, d = line.split(",") # [1, 香蕉, 1.85, 50]
dic[h] = a
dic[i] = b
dic[j] = c
dic[k] = d
lst.append(dic)
print(lst)
f = open("水果", mode="r", encoding="utf-8")
line = f.readline().strip() # 第一行内容, 编号,名称,价格,数量,哈哈
title = line.split(",") # [编号,名称,价格,数量,哈哈]
lst = []
i = 0
for line in f: # 1,香蕉,1.85,50
dic = {} # 每行都是一个字典
line = line.strip() # 去掉空白 \n 1,香蕉,1.85,50
data = line.split(",") # [1, 香蕉, 1.85, 50]
for i in range(len(title)):
dic[title[i]] = data[i]
lst.append(dic)
print(lst)
Python 水果统计的更多相关文章
- python数据统计,总数,平均值等
一般我们进行数据统计的时候要进行数据摸查,可能是摸查整体的分布情况啊.平均值,标准差,总数,各分段的人数啊.这时候用excel或者数据库统计都不方便. 我要统计的一个文件,太大了,还得分成15个文件, ...
- Python代码统计工具
目录 Python代码统计工具 声明 一. 问题提出 二. 代码实现 三. 效果验证 Python代码统计工具 标签: Python 代码统计 声明 本文将对<Python实现C代码统计工具(一 ...
- python数据统计出海品牌
当国内市场处于红海之中时,市场全球化已成为大势所趋.越来越多的国产品牌远走高飞,纷纷将品牌拿出来. 2019年,中国品牌十大品牌中,华为品牌力指数同比增长22%,阿里巴巴品牌力指数增长48%,小米品牌 ...
- Python 代码覆盖率统计工具 coverage.py
coverage.py是一个用来统计python程序代码覆盖率的工具.它使用起来非常简单,并且支持最终生成界面友好的html报告.在最新版本中,还提供了分支覆盖的功能. 官方网站: http://ne ...
- Python制作统计图形
转载自:http://www.dcharm.com/?p=15 Python一般使用Matplotlib制作统计图形,用它自己的说法是‘让简单的事情简单,让复杂的事情变得可能’.(你说国外的“码农”咋 ...
- python 远程统计文件
#!/usr/bin/python #encoding=utf-8 import time import os import paramiko import multiprocessing #统计文件 ...
- python词频统计及其效能分析
1) 博客开头给出自己的基本信息,格式建议如下: 学号2017****7128 姓名:肖文秀 词频统计及其效能分析仓库:https://gitee.com/aichenxi/word_frequenc ...
- HDU 1263(水果统计 **)
题意是对水果的产地和种类进行统计再按格式输出. 代码如下: #include <bits/stdc++.h> using namespace std; struct node { ],pl ...
- 大数据python词频统计之本地分发-file
统计某几个词在文章出现的次数 -file参数分发,是从客户端分发到各个执行mapreduce端的机器上 1.找一篇文章The_Man_of_Property.txt如下: He was proud o ...
随机推荐
- ubuntu server 多网卡
https://wenku.baidu.com/view/51fb15742f60ddccdb38a007.html
- Windows10中注册 regsvr32 xxx.ocx报错but the call to DIIRegisterServer failed with error code 0x80040200
网站中有读取居民身份证的机器,需要安装一些注册activeX控件然后进入指定目录下执行以下命令regsvr32 xxx.ocx报了个错: but the call to DIIRegisterServ ...
- Python day6_dictionary字典的常见方法1_笔记(基本类型结束)
# 字典的简述 # 1.字典不能做字典的key,列表也不能作为列表的key info={ 'k1':'v1', 'k2':'v2' } print(info) #2.通过键获取值 print(info ...
- 《剑指offer》第六题(重要!从尾到头打印链表)
文件main.cpp // 从尾到头打印链表 // 题目:输入一个链表的头结点,从尾到头反过来打印出每个结点的值. #include <iostream> #include <sta ...
- 真核生物基因结构 & mRNA结构
参考: 分子生物学教材 再一次,翻看真核生物基因结构! mRNA基本结构特点 Structure and function of Messenger RNA (mRNA ) 基因结构 其实这个结构不完 ...
- 清空mailq 队列里面的邮件
tmp_=`mailq | grep -E "root" | awk '{print $1}'` for i in $tmp_;do postsuper -d $i;done po ...
- LeetCode--175--组合两个表
问题描述: 表1: Person +-------------+---------+ | 列名 | 类型 | +-------------+---------+ | PersonId | int | ...
- JS-Object(3) 继承(prototype方式, 类方式); javascript6的知识(部分)
原型方式的继承 创建child object classes(constructors) , 子类如何从父类中继承特性. 原型链继承prototypal inheritance (ruby中的继承也是 ...
- Authentication failed (rejected by the remote node), please check the Erlang
官网提供的解决方案 Synchronise Erlang Cookies (when running a manually installedWindows Service) Erlang Secur ...
- response.setHeader的各种用法 ------ 笔记(一)
转载地址:https://blog.csdn.net/junmoxi/article/details/76976692 1.一秒刷新页面一次 response.setHeader("refr ...