我正在學習python,並被困在一個教程上,只要指南應該工作,但不是,我已經看到類似的問題,但不能理解它們如何應用於我所遵循的代碼,代碼在最後一行結尾處失敗。Python串聯錯誤
import os
import time
source = ["'C:\Users\Administrator\myfile\myfile 1'"]
target_dir = ['C:\Users\Administrator\myfile']
target = target_dir + os.sep + \
time.strftime('%Y%m%d%H%M%S') + '.zip'
can only concatenate list (not "str") to list
我一直在使用.append並通過添加[]和()到+「的.zip」,但都無濟於事改變代碼嘗試了一些方法,所以我希望有人可以解釋爲什麼它的失敗以及我如何糾正它。
我使用的Python 2.7.9在Windows
感謝
您使用的是什麼教程? – Kevin 2015-04-02 17:09:43
爲什麼'source'和'target_dir'列表? – 2015-04-02 17:10:33
我不確定這只是教程是如何編碼的,教程是用於備份腳本的,教程是swaroop的一個python字節 – Ambush 2015-04-02 17:15:13