TypeError:只能将列表(不是" str")连接到listt

时间:2017-11-21 09:24:17

标签: python concatenation

亲爱的Python专业人士,请按照下面提到的代码提供帮助:

['1015.KL', '6399.KL', '6888.KL', '4162.KL', '1023.KL', '6947.KL', '3034.KL']

我的预期结果是:

// From arabic letter Ḍād to its one byte code (Win-1256)
byte code = Encoding.GetEncoding(1256).GetBytes("\u0636")[0];
// From code back to arabic letter 
char back = Encoding.GetEncoding(1256).GetString(new byte[] { code })[0];

Console.WriteLine($"{back} == {code} (\\u{(int)back:x4})");

2 个答案:

答案 0 :(得分:1)

klci = ['1015', '6399', '6888', '4162', '1023', '6947', '3034']
klse = '.KL'
tickers = [x + klse for x in klci]

print(tickers)

<强>输出:

['1015.KL', '6399.KL', '6888.KL', '4162.KL', '1023.KL', '6947.KL', '3034.KL']

答案 1 :(得分:0)

我不是专业人士。但是,如果这是我的代码

klci = ['1015', '6399', '6888', '4162', '1023', '6947', '3034']
klse = '.KL'
for ele in range(len(klci)):
   klci[ele] += klse
tickers = klci
print(tickers)

运作良好:D