简体   繁体   English

日志文件名的参数无效

[英]Invalid argument for log file name

Here is what I try to do and I use windows and Python 3.3 这是我尝试做的事情,我使用Windows和Python 3.3

LOG_FILENAME = 'log_trial_%s.txt' % datetime.datetime.now().strftime('%m%d-%H:%M:%S')
log_fd = open(LOG_FILENAME, 'w')
log_fd.write('===================\n')

The above codes are of course a part of a module and whe I ran the module, I got an error message as follows: 上面的代码当然是模块的一部分,当我运行该模块时,出现如下错误消息:

log_fd = open(LOG_FILENAME, 'w')
OSError: [Errno 22] Invalid argument: 'log_trial_1209-11:39:40.txt'

I have no idea what the long weird log finame means ('log_trial_%s.txt' ...) and how to fix the error thing as well. 我不知道长奇怪的日志文件名是什么意思('log_trial_%s.txt'...),以及如何解决该错误。

I will appreciate your time and help. 感谢您的宝贵时间和帮助。

Windows file names can't have colons in them. Windows文件名中不能包含冒号。

Try this instead: 尝试以下方法:

LOG_FILENAME = 'log_trial_%s.txt' % datetime.datetime.now().strftime('%m%d-%H%M%S')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM