我有一个执行以下操作的python3.6循环:
childrenList = []
output["text"] = path
for item in sorted(os.listdir(path)):
contentFullPath = os.path.join(path, item)
children = {}
if os.path.isfile(contentFullPath):
print("item = "+str(item))
children["text"] = item
print("children = "+str(children))
children["id"] = contentFullPath
childrenList.append(children)
我得到以下输出:
web_1 | item = Obamaééé.mp4
web_1 | children = {'icon': 'jstree-file', 'text':
'Obamae\udccc\udc81e\udccc\udc81e\udccc\udc81.mp4'}
为什么变量名为children的文本无法正确显示?
答案 0 :(得分:-1)
import unidecode
text = 'Obamaééé.mp4'
strip_text = unidecode.unidecode(text.decode('utf-8'))
print(strip_text)
[output] : Obamaeee.mp4
希望这对您有所帮助。