python脚本在windows下无报错在linux下会有回报缩进错误为什么

quhanlin123 2016-08-29 11:40:23
#!/usr/bin/env python
# coding=utf-8

import ConfigParser

def singleton(cls, *args, **kw):
instances = {}
def _singleton():
if cls not in instances:
instances[cls] = cls(*args, **kw)
return instances[cls]
return _singleton

@singleton

class configs(object):

def __init__(self):
self.ConfigParser = ConfigParser.ConfigParser()
self.ConfigParser.read("config.conf")

def get(self,section,option,types=None):
global result
if section is not None:
sectionall = self.ConfigParser.sections()
for sec in sectionall:
if sec == section:
optionall = self.ConfigParser.options(sec)
if optionall is not None:
for opt in optionall:
if opt == option:
if types == "int":
result = self.ConfigParser.getint(sec,opt)
else:
result = self.ConfigParser.get(sec,opt)
return result



缩进感觉没什么问题求大虾指点万分感谢!
...全文
465 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
luoyanhanhan 2016-09-06
  • 打赏
  • 举报
回复
报错信息是什么,截个图看看
nieoding 2016-09-06
  • 打赏
  • 举报
回复
经验之谈: 用sublime打开文件,有缩进问题会提示出来的,
quhanlin123 2016-08-30
  • 打赏
  • 举报
回复
这个我已经直接在服务器上编辑了一遍,全部是按4个空格的
xSeeker~ 2016-08-30
  • 打赏
  • 举报
回复
我感觉问题在于,windows和linux下的换行不一样,你可以在Linux下重新输入输入换行试试
CDSoftwareWj 2016-08-30
  • 打赏
  • 举报
回复
那就真不知道了
CDSoftwareWj 2016-08-29
  • 打赏
  • 举报
回复
你严格按4空格,格式化一边,不同IDE对tab解释估计不一样 严格按4空格是一点问题都没有的

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧