2014-09-26 25 views
0

一直在尋找解決方案一整天,但沒有任何幫助。 無論如何,我一直在試圖做的是將一個日期和時間添加到無線網絡流記錄的文件名。但我不斷收到錯誤消息:Python:添加日期和時間到電臺網頁流記錄

File "streamrunskyplus.py", line 9, in filename = 'home/somebody/streams/streamrunskyplus.py'%datetime.datetime.utcnow().strftime("%Y%m%d-%H%M%S") TypeError: not all arguments converted during string formatting

這裏是你必須把一個%在你的第一個字符串代碼本身

import subprocess 
import os 
import datetime 

os.system("command") 
subprocess.call(['streamripper', 'http://stream05.akaver.com/skyplus_low.ogg', '-d', './streams', '-l', '20', '-a', 'Skyplus', ]) 

filename = 'home/somebody/streams/streamrunskyplus.py'%datetime.datetime.utcnow().strftime("%Y%m%d-%H%M%S") 

回答

2
filename = 'home/somebody/streams/streamrunskyplus.py'%datetime.datetime.utcnow().strftime("%Y%m%d-%H%M%S") 

。 'home/somebody/streams/streamrunskyplus.py'

把%s放在你想放置日期的地方。

例子:如果你想要把它放在結尾:

的家/人/流/ streamrunskyplus.py%s'的

會做的伎倆