python 创建txt每行写入
txtPath=os.path.join(vocDir,"eval.txt")
with open(txtPath,"w") as f:
f.writelines("allGroundBoxNum:{}\n".format(groundBoxNum))
f.writelines("allDetectedBoxNum:{}\n".format(detectedBoxNum))
f.writelines("allDetectedBoxRightNum:{}\n".format(detectedBoxRightNum))
f.writelines("allDetectedBoxAndClassificationRightNum:{}\n".format(detectedBoxAndClassificationRightNum))
f.writelines("识别错误的框的个数:{}\n".format(detectedBoxNum - detectedBoxRightNum))
f.writelines("识别错误的框的个数/预测的框:{}\n".format((detectedBoxNum - detectedBoxRightNum) / detectedBoxNum))
f.writelines("识别对的框/所有的框:{}\n".format(detectedBoxRightNum / groundBoxNum))
f.writelines("框和分类都正确/所有的框:{}\n".format(detectedBoxAndClassificationRightNum / groundBoxNum))
for i in range(len(categories)):
f.writelines("{}的Ground,Detected,DetectedRight个数分别为{},{},{},\n".format(categories[i]["name"],
allGroundClassNumDict[i + ],
allDetectedClassNumDict[i + ],
allDetectedClassRightNumDict[i + ]))
w+表示写入,不存在则创建
写入也可以用python的format,太方便了
python 创建txt每行写入的更多相关文章
- python 创建txt并且写入做追加
import os def create_str_to_txt(self,date,str_data): """ 创建txt,并且写入 """ ...
- python操作txt文件中数据教程[4]-python去掉txt文件行尾换行
python操作txt文件中数据教程[4]-python去掉txt文件行尾换行 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文章 python操作txt文件中数据教程[1]-使用pyt ...
- Python中将变量按行写入txt文本中
案例一: 讲数组a 循环写入名称为2.txt的文档中 # -*-coding:utf8-*- import requests from lxml import etree a=[1,2,3,4,5,6 ...
- python:创建文件夹:写入文本1:读取txt:读取Excel文件遍历文件夹:
https://blog.csdn.net/u011956147/article/details/80369731 创建文件夹: import osimport shutil def buildfil ...
- java按行读取txt并按行写入
IO流想必大家都很熟悉了,本次实现的需求是按行读取文件内容并且按行写入,代码如下: try { String encoding="utf-8"; //设定自己需要的字符编码集 Fi ...
- JAVA 创建TXT文件,写入文件内容,读取文件内容
[java] view plain copy package com.abin.facade.ws.mail.function; import java.io.BufferedReader; i ...
- Java创建TXT文件并写入 内容
public static void main(String[] args) { String filePath = "E:/" + "1.txt"; Stri ...
- python将列表按行写入csv
import csv rows2 = ['abc1/ab1c','N'] for n in range(10): f = open("ok.csv", 'a',newline='' ...
- 文件的创建,读取,写入,修改,删除---python入门
转自:http://blog.163.com/jackylau_v/blog/static/175754040201181505158356/ 一.用Python创建一个新文件,内容是从0到9的整数, ...
随机推荐
- css---6伪元素选择器
after :在内容后边 <!DOCTYPE html> <html lang="en"> <head> & ...
- leetcode-第10周双周赛-5080-查找两颗二叉搜索树之和
题目描述: 自己的提交: class Solution: def twoSumBSTs(self, root1: TreeNode, root2: TreeNode, target: int) -&g ...
- Java 多线程 - 死锁deadlock产生原因+避免方法
ref: java中产生死锁的原因及如何避免 https://blog.csdn.net/m0_38126177/article/details/78587845 java如何避免死锁 http:// ...
- 数论剩余系——cf1089F
关于模和互质,很好的题目 /* n两个质因子 x,y有 ax+by=n-1 ax+by=n-1 ax+1+by=n y|ax+1 gcd(x,y)=1 ax%y,a取[1,y-1],就会有[1,y-1 ...
- js 自适应容器宽高
var echartsWarp= document.getElementById('echartsWarp'); var resizeWorldMapContainer = function () { ...
- Unable to find explicit activity class报错问题解决方法
转:http://hi.baidu.com/mz_mz/item/f5672ad814e1ce30e2108f69 1.首先查看是否在已经在AndroidMainfest.xml中添加了你的Activ ...
- hdu多校第三场 1006 (hdu6608) Fansblog Miller-Rabin素性检测
题意: 给你一个1e9-1e14的质数P,让你找出这个质数的前一个质数Q,然后计算Q!mod P 题解: 1e14的数据范围pass掉一切素数筛法,考虑Miller-Rabin算法. 米勒拉宾算法是一 ...
- USACO 2012 March Silver Tractor /// 优先队列BFS oj21567
题目大意: 输入n,(x,y):n为阻挡的草堆数量,(x,y)为开始时拖拉机所在的位置 接下来n行每行一个坐标(a,b):为各个草堆的坐标 输出拖拉机要回到原点(0,0)需要移动的草堆数量 Sampl ...
- VMware Workstation 10 配置Ubuntu环境
分享到 一键分享 QQ空间 新浪微博 百度云收藏 人人网 腾讯微博 百度相册 开心网 腾讯朋友 百度贴吧 豆瓣网 搜狐微博 百度新首页 QQ好友 和讯微博 更多... 百度分享 VMware Work ...
- 在Eclipse中修改Jsp页面的新增模板
打开Eclipse的Preferences页面 路径: Window à Preferences 搜索"jsp",点击"Templates",选择要修改的Jsp ...