1、MySQL 45题分类总结。
2、python基础部分的视频过了一遍
之前学习过python基础,其中比较不熟悉的是文件操作。在这里再过一遍。
1.1. 文件打开
f = open('test.txt','w') 格式为 open(文件名, 访问模式)
r 以只读方式打开文件。文件指针会放在文件的开头。这是默认模式。
w 打开一个文件只用于写入。如果该文件已存在,则将其覆盖。不存在则新建。
a打开一个文件用于追加。
r+ 打开一个文件用于读写。
w+ 打开一个文件用于读写。如果该文件已存在,则将其覆盖。不存在则新建。
a+ 打开一个文件用于读写。如果该文件已存在,文件指针将会放在文件的结尾。文件打开是会是追加模式。不存在则新建文件用于读写。
1.2. 关闭文件
f.close()
2.1. 写数据
f = open('test.txt','w')
f.write('hello world, i am here!')
f.close
2.2. 读数据
read(num) num表示从文件读取的数据长度
f = open('test.txt','r')
content = f.read(5)
print(content)
print("-" * 30)
content = f.read()
print(content)
f.close()
2.3. 读数据readlines
按照行的方式把整个文件的内容进行一次性读取,并且返回一个列表。
f = open('test.txt','r')
content = f.readlines()
print(type(content))
i = i
for temp in content:
print("%d:%s"%(i,temp))
i += 1
f.close()
应用: 创建文件的备份
# 提示输入文件
oldFileName = input("请输入要拷贝的文件名字:“)
# 以读的方式打开文件
oldFile = open(oldFileName,"rb")
# 提取文件的后缀
fileFlagNum = oldFileName.rfind('.')
if fileFlagNum > 0:
fileFlag = oldFileName[fileFlagNum:]
# 组织新的文件名
newFileName = oldFileName[:fileFlagNum] + "[复件]" + oldFileName[fileFlagNum:]
# 创建新文件
newFile = open(newFileName, 'wb')
# 把旧文件的数据,一行一行的写入复制到新文件中
for contentline in oldFile.readlines():
newFile.write(contentline)
# 关闭文件
oldFile.close()
newFile.close()
3. 文件和文件夹的操作
3.1 文件重命名
os模块中的rename() 可以完成对文件的重命名操作
rename(需要修改的文件名, 新的文件名)
import os
os.rename("毕业论文.txt", "毕业论文-最终版.txt")
3.2 删除文件
os模块中的remove()可以完成对文件的删除操作
remove(待删除的文件名)
import os
os.remove(”毕业论文.txt")
3.3 创建文件夹
import os
os.mkdir("张三")
3.4 获取当前目录
import os
os.getcwd()
3.5 改变默认目录
import os
os.chdir("test") # 跳转到当前路径的test子目录中
3.6 获取目录列表
import os
os.listdir()
3.7 删除文件夹
import os
os.rmdir("张三")
3、和鲸pandas练习
第二次刷和鲸的pandas练习题,整理了不熟悉的用法。
4、可视化部分
涵盖三个包matplotlib, seaborn, pyecharts 一个对于pandas API的画图应用。
目前对seaborn, pyecharts 的掌握程度不高。