解锁式学习
1人加入学习
(0人评价)
Python基础知识学习
价格 免费
该课程属于 949-刘同学-python方向-python数据分析-就业:否 请加入后再学习

import csv

def csv_write():

    headers = ["编号","课程","讲师"]

    rows = [

        (1,'Python','Eason'),

        (2,'C#,'Eason'),

        (1,'.NET','Eason')

    ]

    with open('mu_course.csv','w',encoding = 'utf8',newline = '' ) as f:

        writer = csv.writer(f)

        writer.writerow(headers)

        writer.writerows(rows)

 

def csv_writer_dict()

    headers = ['ID','Title','Org','Url']

    rows = [

    {'ID':1, 'Title': 'Python', 'Org': 'Youpinketang','Url':'uke.cc'}

    ]

    with open ('my_course2.csv','w', encoding = 'utf8') as f:

    writer = csv.DictWriter(f,headers)

    writer.writeheader()

    writer.writerows(rows)

 

 

if __name__ =='__main__':

    csv_writer()

 

 

 

 

json

import json

 

def jason_basic()

    data = {

        "ID":1

        "课程":"优品课堂"

        "单价":"98.00"

    }

    json_str = json.dumps(data)

    json_data = json.loads(json_str)

 

def json_writer_filr():

    data = {

        "ID":1

        "课程":"优品课堂"

        "单价":"98.00"

    }

    with open('data.json','w',encoding='utf8') as f:

        json.dump(data,f)   //不是写在字符串,而是直接写在文档,所以dump后不用s

 

 

def json_read_filr():

    with open('data.json','r',encoding = 'utf8') as f:

        data  = json.load(f)

        print(data)

 

def json_type_diff():

    print(json.dumps(False))

 

 

if __name__=='__main__':

 

 

 

excel

 

import xlrd

 

def xl_read()

    book = xlrd.open_workbook('product.xls')

    for sheet in book.sheets():

        print(sheet.name)

 

def xl_read_dada():

    book = xlrd.open_workbook('product.xls')

    sheet = book.sheet_by_name("Product")

    print('工作簿':{}.format(sheet.name))

    print('数据行数':{}.format(sheet.rows))

    print('产品数据')

    for i in range(sheet.rows):

        print(sheet.row_values(i))  //获取索引指定的数据行

 

 

[展开全文]

授课教师

高级算法工程师
老师

课程特色

视频(61)
考试(14)
练习(12)

最新学员