调用我的打印功能时无法解决错误 \x93

can't resolve error \x93 when call my print function

我正在重新发布问题,因为未解决或回答效率低下,并填充了一些缺失的信息。 在我的打印函数的循环中多次迭代没有问题之后,我遇到了这个我无法弄清楚的错误:UnicodeEncodeError: 'charmap' codec can't encode character '\x93' in position 0: character maps to <undefined>,但是。你会在下面的回溯中看到更好的结果。

j 是一个字符串(我在文件中引用时使用的标志..你可以使用任何..); h 在传递函数 prt_tit_gen 时取 gh 的值。 dir_conf+ct 是字符串,分别是要在其中打印的目录和名称文件。 对于我能理解的(因为出现在 spyder debuger 上),文本代码是 utf-8.

例程是(gh 是用于调试目的的“分解”格式):

   gh = j+' -> '+str(' '.join(e))+"\n"
   prt_tit_gen(dir_conf+ct , gh , 'a')

哪里

def prt_tit_gen(d,h,m):
    file1 = open(d, m)
    file1.writelines(h)
    file1.close()

e = [
'zip:GY1 1WW',
'sector:Financial Services',
'longBusinessSummary:Eurocastle Investment Limited is a publicly traded closed-ended investment company that focuses on investing in performing and nonperforming loans and other real estate related assets primarily in Italy. The Company is Euro denominated and is listed on Euronext Amsterdam under the symbol “ECT”. Eurocastle is managed by an affiliate of Fortress Investment Group LLC, a leading global investment manager. For more information regarding Eurocastle Investment Limited and to be added to our email distribution list, please visit www.eurocastleinv.com.',
'city:Saint Peter Port',
'country:Guernsey',
'regularMarketPrice:8.3',
'preMarketPrice:None',
'logo_url:https://logo.clearbit.com/eurocastleinv.com'
]

回溯(最近调用最后):

File "D:\Documenti\Develope\Python\AI\Previsone Titoli\getTiker Sector.py", line 89, in <module>
    prt_tit_gen(dir_conf+ct, j+' -> '+str(' '.join(e))+"\n", 'a')
  File "D:\Documenti\Develope\Python\AI\Previsone Titoli\getTiker Sector.py", line 45, in prt_tit_gen
    file1.writelines(h)
  File "C:\Program Files\Linguaggi\Python397\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\x93' in position 0: character maps to <undefined>

像这样打开指定编码的文件

file1 = open(d, m, encoding="utf-8")