从Windows切换到Linux时,Python脚本出错

时间:2019-03-13 02:46:58

标签: python-3.x error-handling cross-platform

我在Windows上编写了一个Python脚本,并且运行良好,现在我刚刚安装了一个基于Ubuntu的发行版“ elementary Os”,但是有些我在启动脚本时却崩溃了……我现在真的不知道如何修复它。

我让您来解决部分脚本制作问题:

memos=open(str(os.getcwd())+'\\LOG\\tres.txt','w')
menf='3)PRESION LATERAL DEL SUELO DE RELLENO\n Ka = '+str(round(Ka,2))+'\nP = '+str(round(P,2))+'\nY = '+str(round(Y,2))+'''
\nHm = '''+str(round(Hm,2))+'\nPm = '+str(round(Pm,2))+'\nYm = '+str(round(Ym,2))
memos.write(menf)
memos.close()

所以这笔交易应该是...

memos=open(str(os.getcwd())+'\\LOG\\tres.txt','w')

因为给我看一个错误...

UnicodeEncodeError: 'ascii' codec can't encode character '\xba' in position 199: ordinal not in range(128)

现在,当我换......

memos=open(str(os.getcwd())+'/LOG/tres.txt','w')

又给我一个错误...

FileNotFoundError: [Errno 2] No such file or directory: '/home/jojaror/Documentos/Scripts de Python/LOG/tres.txt'

我试图自己解决,但我不能...因此,如果无论如何可以帮助我,这将是有帮助的。

0 个答案:

没有答案