python代码在linux和windows运行不一致问题

相同Python代码在Linux运行时出现UnicodeWarning和SourceChangeWarning,导致.t7文件在Windows下加载报UnicodeDecodeError。问题根源在于Linux Python2.7默认编码为ASCII,而Windows Python3.6使用UTF-8。解决方法是在Linux环境下修改文件编码为UTF-8或在Python脚本中设置编码。
摘要由CSDN通过智能技术生成

问题描述: Windows10,anaconda,python3.6

相同的python代码,在linux运行时提示:

/usr/local/lib/python2.7/dist-packages/torch/serialization.py:255:UnicodeWarning: Unicode unequal comparison failed to convert both arguments toUnicode - interpreting them as being unequal

  iforiginal_source != current_source:

/usr/local/lib/python2.7/dist-packages/torch/serialization.py:286:SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' haschanged. you can retrieve the original source code by accessing the object'ssource attribute or set `torch.nn.Module.dump_patches = True` and use the patchtool to revert the changes.

然后把Linux运行得到的 .t7文件放到Windows下运行,报错:

<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值