现象:

此问题真的是太痛苦了,查了好多资料是说路径的问题,结果还是报错,后来一点点的排查才发现原来是!!!!!!

废话不多说上原来代码:

 if __name__ == '__main__':
startime = time.strftime('%H:%M:%S')
print("开始时间为:%s" % startime)
#测试路径
test_dir = './t/test_case'
#报告路径
report_dir = './t/report/' now = time.strftime('%Y-%m-%d_%H:%M:%S')
# 创建完整报告文件
filename = report_dir + now + '_report.html'
fp = open(filename,'wb')

看到没有!!看第九行,now的获取时间有问题!!!时分秒之间不能用冒号:,不能用冒号:,不能用冒号:,重要的事情说三遍!!!真的要哭了!!!

修改如下:

 if __name__ == '__main__':
startime = time.strftime('%H:%M:%S')
print("开始时间为:%s" % startime)
#测试路径
test_dir = './t/test_case'
#报告路径
report_dir = './t/report/' now = time.strftime('%Y-%m-%d_%H_%M_%S')
# 创建完整报告文件
filename = report_dir + now + '_report.html'
fp = open(filename,'wb')

【Selenium + Python】路径报错之OSError: [Errno 22] Invalid argument: './t/report/2018-03-23_11:03:12_report.html'的更多相关文章

  1. 【Selenium】【BugList9】windows环境,fp = open("./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html",'wb'),报错:OSError: [Errno 22] Invalid argument: './2018-09-05 10:29:32 result.html'

    [代码] if __name__=="__main__": suite = unittest.TestSuite() suite.addTest(Baidu("test_ ...

  2. 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’

    如题,在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: '文件路径',在查阅了大量资料后也得到了一些解决方案,但是这些解决方案 ...

  3. python使用open的OSError: [Errno 22] Invalid argument错误

    这两天在写一个新闻类的spider时,遇到了OSError: [Errno 22] Invalid argument这个错误,苦恼的两天,无果.后来通过请教学长,发现原来是打开的文件名中含有一些系统的 ...

  4. python OSError: [Errno 22] Invalid argument: '\u202aF://text

    windows10 python3 读文件的时候报的错误 原因不明时好时坏很头疼但又没办法不知道怎么解决,网上的说法都不能解决,

  5. python OSError: [Errno 22] Invalid argument: 'D:\\crawle\x01.html1'

    import urllib.request file = urllib.request.open("http://www.baidu.com") data = file.read( ...

  6. tensorboard OSError:[Errno 22] Invalid argument

    哈哈 问题解决了.感谢大佬 Bill.Z 附上原文链接:https://blog.csdn.net/u013244846/article/details/88380860 解决方法:更改manager ...

  7. OSError: [Errno 22] Invalid argument: 'D:\x07ckup\test.txt'

    使用with open("D:\backup\test.txt","rt") as f:报上面的错误,将上面的语句改成 with open(r"D:\ ...

  8. Python创建文件报错OSError:[Errno 22] Invalid argument处理

    问题: windows平台下使用python open函数w模式打开文件报错“OSError: [Errno 22] Invalid argument: '../news/“消费升维”成零售业新风口? ...

  9. 训练DQN,报错:OSError: [Errno 12] Cannot allocate memory

    训练DQN,报错:OSError: [Errno 12] Cannot allocate memory 问题介绍: 这两天在做强化学习的作业,使用 DQN 打 Atari 游戏,但在训练过程中,出现了 ...

随机推荐

  1. hdu 1847 Good Luck in CET-4 Everybody! 组合游戏 找规律

    题目链接 题意 有\(n\)张牌,两人依次摸牌,每次摸的张数只能是\(2\)的幂次,最后没牌可摸的人为负.问先手会赢还是会输? 思路 0 1 2 3 4 5 6 7 8 9 10 11 -- P N ...

  2. 【Visual Studio】“rc.exe”已退出,代码为 5 ("rc.exe" exited with code 5.)

    [解决方案]找到 rc.exe 所在目录,然后 方法1:添加该目录到 VC++ Directories --> Executable Directories中 方法2:添加到系统变量中的Path ...

  3. AC日记——仙岛求药 openjude 2727

    仙岛求药 思路: bfs: 来,上代码: #include <cstdio> #include <cstring> #include <iostream> #inc ...

  4. mysql查询练习题

    建库建表 a.建立一个公司数据库(gongsi)    CREATE DATABASE gongsi b.建立一张部门表(部门编号b_id,部门名称b_name) ,             其中b_ ...

  5. SpringBoot 分包方式多数据源

    1.引入依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spri ...

  6. 创建一个vue-cli项

    一.vue cli脚手架 Vue 提供了一个官方的cli,为单页面应用 (SPA) 快速搭建繁杂的脚手架,通过这个工具我们就可以很方便的来创建一个基于vue的项目. 二.安装一些必要的东西node.n ...

  7. python画直线

    #!/usr/bin/env python import matplotlib.pyplot as plt import numpy as np #beita = 1 #gama = 0.5 #x:f ...

  8. ELK之filebeat替代logstash收集日志

    filebeat->redis->logstash->elasticsearch 官网下载地址:https://www.elastic.co/downloads/beats/file ...

  9. poj 1185 炮兵阵地 [经典状态压缩DP]

    题意:略. 思路:由于每个大炮射程为2,所以如果对每一行状态压缩的话,能对它造成影响的就是上面的两行. 这里用dp[row][state1][state2]表示第row行状态为state2,第row- ...

  10. 以root用户身份在jenkins中运行shell命令

    以下过程是CentOS 1.打开此脚本(使用VIM或其他编辑器): vim /etc/sysconfig/jenkins 2.找到$JENKINS_USER并更改为“root”: $JENKINS_U ...