substring用法 - str取代python

我如何在Python中將一個字符串列表加入到一個字符串中 (1)

我正嘗試使用.join()方法將字符串列表連接到一個字符串中。 然而,看起來結果仍然是相同的地方,輸出仍然產生一個字母表,而不是一個字。 這是相關的代碼:

import sys
import traceback
import weka.core.jvm as jvm
#import wekaexamples.helper as helper
from weka.core.converters import Loader
from weka.classifiers import Classifier

def main(args):
# load a dataset
 loader = Loader(classname="weka.core.converters.ArffLoader")
 train = loader.load_file("C:/Users/Syahirah/Desktop/Train_FYP.arff")
 train.class_index = train.num_attributes - 1
 test = loader.load_file("C:/Users/Syahirah/Desktop/Test_FYP_prediction.arff")

# classifier
 cls = Classifier(classname="weka.classifiers.bayes.NaiveBayes")

# output predictions
#print("ID - actual - predicted ")
 for index, inst in enumerate(test):
    #print "\n", inst
    varinst = str(inst)
    #print type(varinst),varinst
    split_inst = varinst.split(',') 
    kata = split_inst[1]
    semua = ' '.join(kata)
    print semua


T h e
c u s t o m e r s
a r e
a l l o w e d
t o
r e s e r v e
r o o m
o n l i n e
b y
t h e
w a y
t h e y
a b l e
t o
c h a n g e
o r
c a n c e l
t h e i r
r e s e r v a t i o n


The customers are allowed to reserve room online, by the way they able to 
change or cancel their reservation


from __future__ import print_function


semua = ' '.join(kata)
print semua


semua = ''.join(kata)
print(semua, end='')