當前位置:成語大全網 - 新華字典 - python 字典的值為列表,想把壹個列表的值拼在壹起用‘\t’隔開,變成壹個字符串怎麽寫?

python 字典的值為列表,想把壹個列表的值拼在壹起用‘\t’隔開,變成壹個字符串怎麽寫?

dic = {'name': ['zhang', 'li', 'wang'], 'sex': ['male', 'female'],'sentence': ['I am a student.', 'I like playing the piano.', 'I want to go out.']}

str0 = ''

for i in dic:

for j in dic[i]:

str0 += j + '\t'

str0 = str0.strip('\t')

dic[i] = str0

str0 = ''

print(dic)

這裏雖然打印出來帶有\t,但是實際上他就是制表符,我分別打印出值妳看看: