Python TypeError:并非所有参数都在字符串格式化datetime期间转换

Python TypeError:并非所有参数都在字符串格式化datetime期间转换,python,string,Python,String,当我写上面的代码时,我得到了以下错误,我不明白为什么我所有的参数都是字符串。我感觉问题出在我放置空间支架的方式上,但我无法解决它 log_dir = os.path.abspath(os.path.join(__file__ , "../../", 'logs')) log_file_path = os.path.join(log_dir, 'Params.txt' % datetime.strftime(datetime.today(), '%Y%m%d')) 这就是你要找的吗 TypeEr

当我写上面的代码时,我得到了以下错误,我不明白为什么我所有的参数都是字符串。我感觉问题出在我放置空间支架的方式上,但我无法解决它

log_dir = os.path.abspath(os.path.join(__file__ , "../../", 'logs'))
log_file_path = os.path.join(log_dir, 'Params.txt' % datetime.strftime(datetime.today(), '%Y%m%d'))

这就是你要找的吗

TypeError: not all arguments converted during string formatting

我不太确定你想用Params.txt和日期做什么?您似乎想在文件名中存储日期?如果是这样,我已将其设置为获取从datetime返回的值,将其存储在元组中,并将其传递到文件名中。

您希望
'Params.txt'%datetime.strftime(datetime.today(),'%Y%m%d')
返回什么?
log_file_path = os.path.join(log_dir, '%s.txt' % (datetime.strftime(datetime.today(), '%Y%m%d'),))