#!python3 # -*- coding:utf-8 -*- #CSV stands for "comma-separated values",and CSV files are simplified spreadsheets stored as plaintext files. #CSV 以文本的形式存储Excel类型的数据,每个数据以逗号分隔 #JSON(is short for JavaScript Object Notation) is a format that sto…
也没啥,记下来怕忘了.说明都在代码里面: 麻蛋,这个着色好难看 import csv import json #从txt变为csv student_txt=[]; with open("student.txt",mode='r',encoding='utf-8')as student_txt_file_name: for i in student_txt_file_name.readlines(): student_txt.append(i.strip('\n').split(&quo…
CSV文件读取: Csv文件格式如下:分别有2行三列. 访问代码如下: f=open(r'E:\py_prj\test.csv','rb') f_csv=csv.reader(f) for f in f_csv: print f 在这里f是一个元组,为了访问某个字段,需要用索引来访问对应的值,如f[0]访问的是first,f[1]访问的是second,f[2]访问的是third. 用列索引的方式很难记住.一不留神就会搞错.可以考虑用对元组命名的方式 这里介绍namedtuple的方法.…
1.使用FileStream读写文件 文件头: using System; using System.Collections.Generic; using System.Text; using System.IO; 读文件核心代码: byte[] byData = new byte[100]; char[] charData = new char[1000]; try { FileStream sFile = new FileStream("文件路径",FileMode.Open);…
因为经常使用数据格式,所以将它封装成类,J这样就不会用到时就写了,直接调用写好的类就可以了 (1)dataType数据格式为:TEXT格式的数据是字符串的数据,在"ajax对数据进行删除和查看"的那篇博客中说过,这里在说下 结果不会每个传输的都是字符串,有时是二维数组,这样就要转换为字符串格式了 class DBDA { public $host="localhost"; //数据库连接 public $uid="root"; //用户 publ…
JSON序列化现在应用非常多,尤其在前后端分离的情况下,平常大多数C#下都使用Newtonsoft.Json来操作,量少的情况下,还可以忽略,但量大的情况下就要考虑使用ServiceStack.Text来操作,序列化性能差不多,反序列化性能要高一倍左右 ; User user = , Name = , Status = true }; string temp = String.Empty; User user1 = new User(); string temp1 = "{\"Id\&…
1.python读写csv文件 import csv #读取csv文件内容方法1 csv_file = csv.reader(open('testdata.csv','r')) next(csv_file, None) #skip the headers for user in csv_file: print(user) #读取csv文件内容方法2 with open('testdata.csv', 'r') as csv_file: reader = csv.reader(csv_file)…