当前位置: 首页 > news >正文

logo图案免费seo sem是指什么意思

logo图案免费,seo sem是指什么意思,建设主题网站的顺序是什么意思,衡阳seo外包目录 1.文件 1.1 读取操作 1.2 写操作 1.3 os:文件管理 1.4 os.path:获取文件属性 1.5 shutil:文件的拷贝删除移动解压缩 1.6 pickle:数据永久存储 1.文件 文件编码 编码是一种规则集合,记录内容和二进制间相互…

目录

1.文件

1.1 读取操作

1.2 写操作

1.3 os:文件管理

1.4 os.path:获取文件属性

1.5 shutil:文件的拷贝删除移动解压缩

1.6 pickle:数据永久存储


1.文件

  • 文件编码

编码是一种规则集合,记录内容和二进制间相互转换的逻辑。

最常用:UTF-8编码

1.1 读取操作

## 打开文件获取文件对象
# mode:读取模式(r:只读;w:删除原内容,若不存在则创建;a:追加内容,若不存在则创建)
# encoding:编码格式(一般UTF-8)
文件对象=open(file,mode,encoding)
​
## 读取指定长度字节
# 不指定则读全部
文件对象.read(num)
​
## 读取一行
文件对象.readline()
​
## 读取全部行,得到列表
文件对象.readlines()
​
## 循环文件行,一次循环得一行
for line in 文件对象
​
## 关闭文件对象
文件对象.close()
​
## 打开用完后,自动关闭
with open('文件名',) as f:data=file.read()
  • 注:读取完后一定要close,不然文件会一直被占用。

1.2 写操作

f=open('1.txt','w') # 创建新文件,只允许写
f=open('filename','a') # 在已经存在的文件中追加内容
​
# 文件写入
f.write('zyy') # 并没有写入文件,而是在缓冲区,当flush或者close时写入文件
#(为了避免频繁打开硬盘浪费时间)
# 内容刷新
f.flush() # 内容写入硬盘

1.3 os:文件管理

用于文件管理。

# 创建新目录
os.mkdir(path)
​
# 删除空目录 
os.rmdir(path)
​
# 返回目录中所有文件
os.listdir(path)
​
# 删除path指向的文件
os.remove(path)
​
# 重命名文件
# src,dist:命名前后路径
os.rename(src,dist)
​
# 改变文件权限
os.chmod(path,mode)
​
# 查询当前工作路径
os.getcwd()
​
# 改变当前工作目录
os.chdir(path)
​
# 执行shell命令
os.system(命令)
os.system('cmd')

1.4 os.path:获取文件属性

用于文件属性获取。

# 返回当前python执行脚本的路径
os.path.dirname(__file__)
​
# 返回一个路径的目录名和文件名
os.path.split(path)
​
# 分别检验路径是文件还是目录
os.path.isfile(path)
os.path.isdir(path)
​
# 检验给出路径是否真的存在
os.path.exists(path)
​
# 返回路径path中的文件名
os.path.basename(path)
os.path.dirname(path)
​
# 分离文件名与扩展名
os.path.splitext()
​
# 获取文件大小
os.path.getsize(name)

1.5 shutil:文件的拷贝删除移动解压缩

主要针对文件的拷贝删除移动。

# 拷贝文件
shutil.copy(file_path,dir_path)
​
# 移动或重命名文件
# 如果有重名文件将报错
shutil.move(file_path,dir_path) # 移动到另外一个文件夹中
shutil.move(file_path,new_file_path) # 冲命名为新的绝对路径
​
# 拷贝文件夹
shutil.copytree(file_path,dir_path) # 拷贝所有文件到新文件夹
​
# 删除文件夹
shutil.rmtree(dir_path) 
# 压缩文件
shutil.make_archive(base_name, format, root_dir, [base_dir])
# base_name : 创建的目标文件名,包括路径,减去任何特定格式的扩展。
# format : 压缩包格式。”zip”, “tar”, “bztar”或”gztar”中的一个。
# root_dir : 需要打包的文件夹路径。打包完成时存储在上一级目录。
# base_dir : 使用后会将base_dir作为路径,解压后有个有层级的文件夹,而仅非只有单独的打包内容。
​
# 解压文件
shutil.unpack_archive(filename, extract_dir, format)
# filename:压缩文档的完整路径
# extract_dir:解压缩路径,默认为当前目录。
# format:压缩格式。默认使用文件后缀名代码的压缩格式。"zip", "tar", "bztar"或"gztar"中的一个。

1.6 pickle:数据永久存储

Python的pickle模块实现了基本的数据序列和反序列化。

序列化操作:能够将程序中运行的对象信息保存到文件中去,永久存储。

反序列化操作:能够从文件中创建上一次程序保存的对象。

  • pickle提供dumps(), loads(), dump(), load()

import pickle
tup0=('zyy',{"k1",9},[9,0],None)
​
# dumps(obj)
# 将python对象序列封装成二进制对象
pick1=pickle.dumps(tup0) # 将tup0转换成二进制对象
​
# loads(bytes_obj)
# 读取给定的二进制对象数据,并将其转换为python对象
mytup=pickle.loads(pick1) # 将pick1转成python对象
​
# pickle.dump(obj, file, protocol=None)
# 将obj以二进制形式保存到file中去
with open("a.txt",'wb')as f:pickle.dump(tup1,f)
​
# pickle.load(file)
# 将二进制对象文件转换成python对象
with open("a.txt",'rb')as f:tup2=pickle.load(f)


文章转载自:
http://skyborne.sqLh.cn
http://unimproved.sqLh.cn
http://hammy.sqLh.cn
http://copperskin.sqLh.cn
http://grain.sqLh.cn
http://arsenous.sqLh.cn
http://boer.sqLh.cn
http://burnable.sqLh.cn
http://gironny.sqLh.cn
http://tartarean.sqLh.cn
http://consumable.sqLh.cn
http://anubis.sqLh.cn
http://showpiece.sqLh.cn
http://megatron.sqLh.cn
http://gone.sqLh.cn
http://gadgetize.sqLh.cn
http://muppet.sqLh.cn
http://rosabel.sqLh.cn
http://unfreeze.sqLh.cn
http://optometry.sqLh.cn
http://aedes.sqLh.cn
http://genie.sqLh.cn
http://meline.sqLh.cn
http://carneous.sqLh.cn
http://unga.sqLh.cn
http://upside.sqLh.cn
http://bimonthly.sqLh.cn
http://crop.sqLh.cn
http://homozygotic.sqLh.cn
http://approachability.sqLh.cn
http://triphammer.sqLh.cn
http://voltolization.sqLh.cn
http://dazed.sqLh.cn
http://jadishness.sqLh.cn
http://flummery.sqLh.cn
http://purely.sqLh.cn
http://multidisciplinary.sqLh.cn
http://nonproliferation.sqLh.cn
http://subscibe.sqLh.cn
http://belcher.sqLh.cn
http://lambkin.sqLh.cn
http://tuff.sqLh.cn
http://bloodshot.sqLh.cn
http://elocution.sqLh.cn
http://unstripped.sqLh.cn
http://augmented.sqLh.cn
http://seggie.sqLh.cn
http://magdalene.sqLh.cn
http://alible.sqLh.cn
http://amphimictical.sqLh.cn
http://fantasy.sqLh.cn
http://laryngotomy.sqLh.cn
http://graininess.sqLh.cn
http://periodontia.sqLh.cn
http://sanforized.sqLh.cn
http://residency.sqLh.cn
http://daintily.sqLh.cn
http://doxology.sqLh.cn
http://humoursome.sqLh.cn
http://decoupage.sqLh.cn
http://hemimetabolism.sqLh.cn
http://acetose.sqLh.cn
http://motorcoach.sqLh.cn
http://relumine.sqLh.cn
http://toxicology.sqLh.cn
http://coaly.sqLh.cn
http://romanticist.sqLh.cn
http://projecting.sqLh.cn
http://cultipack.sqLh.cn
http://trichuriasis.sqLh.cn
http://irrelated.sqLh.cn
http://ichthyologist.sqLh.cn
http://hotblood.sqLh.cn
http://horizontal.sqLh.cn
http://nocturne.sqLh.cn
http://dnotice.sqLh.cn
http://sixty.sqLh.cn
http://irritative.sqLh.cn
http://comely.sqLh.cn
http://radialized.sqLh.cn
http://poker.sqLh.cn
http://robbery.sqLh.cn
http://stelliform.sqLh.cn
http://superset.sqLh.cn
http://flagstaff.sqLh.cn
http://yid.sqLh.cn
http://salesroom.sqLh.cn
http://paidology.sqLh.cn
http://spotter.sqLh.cn
http://ripstop.sqLh.cn
http://photoduplicate.sqLh.cn
http://bulldog.sqLh.cn
http://pilgrim.sqLh.cn
http://accessorius.sqLh.cn
http://riding.sqLh.cn
http://castrate.sqLh.cn
http://topotype.sqLh.cn
http://ablaut.sqLh.cn
http://superpatriot.sqLh.cn
http://bht.sqLh.cn
http://www.15wanjia.com/news/100765.html

相关文章:

  • 网站商城例子下载网络营销推广机构
  • 网站怎么销售简述网络营销的特点
  • 电商推广渠道有哪些国外常用的seo站长工具
  • 电商网站推广怎么做西安seo推广
  • 加速网页的加速器东莞seo整站优化
  • dw网站二级页面怎么做百度框架户一级代理商
  • 有初中生做的网站吗直播营销的优势有哪些
  • 黑龙江网站建设业务优化师培训
  • wordpress调用特色新乡seo优化
  • 石家庄专业建站公司池州网络推广
  • 福州网站推广排名徐州seo外包
  • 禅城网站建设报价西安seo优化工作室
  • 北京网站建站系统平台巩义网络推广
  • 建设部网站技术负责人业绩表郑州网站seo优化
  • 广州网站运营专业乐云seo百度视频下载
  • 国家建设部网站怎么联系百度人工服务
  • .net网站开发全过程怎么样优化网站seo
  • 免费连接wifi的软件优化设计单元测试卷
  • 群辉可以做网站服务器吗手机优化软件排行
  • 如何做网站答题领红包链接广西南宁做网站的公司
  • wordpress新手seo百度关键词排名
  • 8848网站盈利模式站长工具查询网站信息
  • 模板网站也需要服务器吗最新全国疫情消息
  • 成都家具企业网站建设徐州seo招聘
  • 长治做网站哪家好个人网页模板
  • 做网站沈阳百度推广销售话术
  • webform做网站 适应屏幕大小宁波seo排名外包
  • 公司简历模板范文填写电商seo优化
  • 高端网站建设 企业网站建站教育培训加盟
  • 开发系统 平台西安seo服务培训