OSError:[Errno 22]无效的参数:Python错误

时间:2020-03-12 19:28:12

标签: python python-3.x windows

这是我的代码:

SELECT DISTINCT
  DAY,
  county,
  CASE WHEN (Date_2 > Date_1) THEN (region)  ) then  (region)
       WHEN (Date_2 = Date_1) THEN MIN(region) Over (Partition By DAY, county)
       ELSE region
       END AS region,
  CASE WHEN (Date_2 > Date_1) THEN  handoff_date
       WHEN (Date_2 = Date_1) THEN  MIN(handoff_date)  Over (Partition By DAY, county)
       END AS date2,
  CASE WHEN (Date_2 = Date_1) THEN MIN(Date_1) Over (Partition By DAY, county) 
       WHEN (Date_2 > Date_1) THEN (Date_1)
       END AS date1,
  CASE WHEN (Date_2 = Date_1) THEN MAX(Date_end) Over (Partition By DAY, county) 
       WHEN (Date_2 > Date_1) THEN (Date_end)
       END AS dateEnd 
FROM table
GROUP BY 1,2,3,4,5

我正在尝试创建具有上述指定格式的文本文件,但被抛出为OSError。有解决此问题的解决方法吗?

谢谢。

1 个答案:

答案 0 :(得分:2)

文件名中不能包含分号。

Date = datetime.today().strftime('%Y-%m-%d-%H:%M:%S')

将此更改为类似

Date = datetime.today().strftime('%Y-%m-%d-%H.%M.%S')