Python-file_analysis

一、文件

1.定义:长久保存信息的一种信息集合

2.常用操作:(1)打开关闭(2)读写内容(3)查找

3.open函数

(1)意义:打开文件,带有很多参数

(2)第一个参数:必须有,文件的路径和名称

mode:表明文件用什么方式打开

i.r代表只读的方式打开;ii.w:写方式打开,会覆盖以前的内容;iii.x代表创建方式打开,如果文件已经存在,则会报错;iv.a代表append方式以追加的方式对文件内容进行写入;v.b代表binary方式,二进制方式写入;vi.t代表文本的方式打开;vii.+代表可读写

#f称之为文件句柄

f = open(r"C:\Users\lenovo1\Desktop\微信公众号运营-Python\新建 Microsoft Word 文档.docx",'w')

#打开之后一定要关闭

f.close()

#案例说明,以写方式打开文件,默认是如果没有这个文件,则会创建

4.with语句

(1)含义:使用的技术是一种成为上下文管理的协议的技术(ContextManagementProtocal)

(2)自动判断文件的作用域,自动关闭不再使用的打开的文件句柄

with open(r"C:\Users\lenovo1\Desktop\Python\新建 Microsoft Word 文档.docx",'r') as f:

    #按行读取内容

    strling = f.readline()

    #磁结构保证能够完整的读取文件直到结束

    while strling:

        print(strling)

        strline = f.readline()

在学习过程中有什么不懂得可以加我的
python学习交流扣扣qun,784758214
群里有不错的学习视频教程、开发工具与电子书籍。
与你分享python企业当下人才需求及怎么从零基础学习好python,和学习什么内容
def get_parser(): parser = argparse.ArgumentParser(description='Face detection and classification for politicians in Japanese TV.') # Important configuration variables parser.add_argument('--dataset', type=str, default='mot17', help='Mode name for saving files.') parser.add_argument('--mode', default='train', type=str, help='train or test.') parser.add_argument('--detector', type=str, default='YOLOX', help='Detector to be used. FRCNN, SDP, Bresee, SGT, YOLOX, GT.') parser.add_argument('--reid', type=str, default=None, help='Reidentification model to be used. SBS, MGN.') parser.add_argument('--mod', type=str, default=None, help='Tracker name modifier to do testing of features.') # Paths parser.add_argument('--datapath', type=str, default='datasets/MOT17Det', help='Dataset path with frames inside.') parser.add_argument('--feat', type=str, default='feats', help='Features files path.') # Tracking-specific configuration variables parser.add_argument('--max_iou_th', type=float, default=0.15, help='Max value to multiply the distance of two close objects.') parser.add_argument('--w_tracklet', type=int, default=10, help='Window size per tracklet') parser.add_argument('--w_fuse', type=int, default=3, help='Window size per fusion in hierarchy') parser.add_argument('--max_prop', type=int, default=10000, help='Difficult the fusion when the frame difference is larger than this value.') parser.add_argument('--fps_ratio', type=int, default=1, help='Use lower fps dataset if lower than 1.') # Flags parser.add_argument('--save_feats', action='store_true', help='Save tracking + feature vectors as pkl file for analysis.') parser.add_argument('--iou', action='store_true', help='Add IoU distance to further improve the tracker.') parser.add_argument('--temp', action='store_true', help='Use temporal distance to further improve the tracker.') parser.add_argument('--spatial', action='store_true', help='Use spatial distance to further improve the tracker.') parser.add_argument('--motion', action='store_true', help='Add motion estimation to further improve the tracker.') parser.add_argument('--randorder', action='store_true', help='Random order of lifted frames for testing.') parser.add_argument('--noncont', action='store_true', help='Do not enforce continuous clustering. Allow all tracklets to cluster with whoever they want.') return parser
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值