【发布时间】:2021-07-28 17:09:44
【问题描述】:
我正在尝试将一些文本附加到 js 文件中,它包含非英语字符,例如 'ç,ş,ı'。
附加文本是动态的,当它包含非英文字符时,js文件中的非英文字符会损坏。
string = '{ "type": "Feature", "properties": { "color": "' + colors[color] + '", "geometry": "Point", "name": " ' + user_input + '", "description": "' + desc + '" }, "geometry": { "type": "Point", "coordinates": [ ' + str(lng) + ', ' + str(lat) + ' ] } },]};'
f = open('mapdata.js', 'a')
f.write(string)
f.close()
【问题讨论】:
标签: python-3.x file write non-english