从Windows到Linux的Python代码 [英] Python code from Windows to Linux

查看:57
本文介绍了从Windows到Linux的Python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些文件带有针对Windows格式化的代码.当我尝试在Linux机器上运行它们时,我遇到了文件编码问题.有人可以为此提出建议吗

I have files with code that is formatted for windows. when I try to run them on linux machine i have problem with file encodings. Can anybody suggest a solution for this

在Windows上运行时,我得到-

on Windows when I run I get -

This was return from redis
Exception in thread Thread-3:
Traceback (most recent call last):
 File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
 File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/bsingh/python_files/lib/Site.py", line 85, in monitor
self.update1()
File "/home/bsingh/python_files/lib/Site.py", line 78, in update1
for entry in new_pastes[::-1]:
TypeError: 'NoneType' object has no attribute '__getitem__'

推荐答案

您应该尝试-

dos2unix <filename> 

要将Windows中创建的文件转换为Unix格式.参考

To convert files created in windows to unix format. Reference

请注意dos2unix是 不是python代码转换 ,它将dos字符转换为与unix等效的字符.

Please note dos2unix, is not python code conversion, it would convert dos characters to unix equivalent.

这篇关于从Windows到Linux的Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆