鱼C论坛

 找回密码
 立即注册
查看: 2678|回复: 11

真是个急啊!有劳各位了!

[复制链接]
发表于 2015-2-27 17:16:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
Traceback (most recent call last):
  File "C:\genesis\sys\scripts\example\example.py", line 16, in <module>
    import genClasses
  File "D:\Python34\lib\genClasses.py", line 285
    def clean(self,strip_me,badchars):
                                                   ^
TabError: inconsistent use of tabs and spaces in indentation

老是报错(上),我查了N遍,就是找不到问题。下面是原文:
def clean(self,strip_me,badchars):
                """ Internal - strips a string (strip_me) of given (badchars) on either edge - used in parsing"""
                badchars = badchars + ' \n'
                l = len(strip_me)
                if l < 1:
                        return ""
                while(len(strip_me) > 0):
                        if strip_me[0] in badchars:
                                strip_me = strip_me[1:]
                        else:
                                break
                x = len(strip_me)-1
                for i in range(x):
                        if strip_me[x-i] in badchars:
                                strip_me = strip_me[:x-i]
                        else:
                                break
                return strip_me      
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2015-2-27 19:20:13 | 显示全部楼层
缩进错误,你不能使用tab和空格混合的缩进。
我建议重新敲一遍。话说你应该是复制粘贴的吧。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2015-2-27 20:41:58 | 显示全部楼层
感谢您的回复,我敲过好几边的啦!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-2-27 22:27:03 | 显示全部楼层
本帖最后由 小龙_h 于 2015-2-27 22:30 编辑

第二行
                """ Internal - strips a string (strip_me) of given (badchars) on either edge - used in parsing"""
前边的缩进去掉,应该就可以啦~
(⊙o⊙)…貌似不是这样
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-3 18:42:45 | 显示全部楼层
不知道是不是你要的其实你可以把题发上来 英语的也没关系 加pylint 也没事
def clean(strip_me,badchars):
    """ Internal - strips a string (strip_me) of given (badchars) on either edge - used in parsing"""
    badchars = badchars + ' \n'
    l = len(strip_me)
    if l < 1:
        return ""
    while(len(strip_me) > 0):
        if strip_me[0] in badchars:
            strip_me = strip_me[1:]
        else:
            break
    x = len(strip_me)-1
    for i in range(x):
        if strip_me[x-i] in badchars:
            strip_me = strip_me[:x-i]
        else:
            break
    return strip_me


print(clean('aasasdasasdaaaaaaa','asasasasasa'))
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-3 18:49:23 | 显示全部楼层
def clean(strip_me,badchars):
        """ Internal - strips a string (strip_me) of given (badchars) on either edge - used in parsing"""
        badchars = badchars + ' \n'
        l = len(strip_me)
        if l < 1:
                return ""
        while(len(strip_me) > 0):
                if strip_me[0] in badchars:
                        strip_me = strip_me[1:]
                else:
                         break
        x = len(strip_me)-1
        for i in range(x):
                if strip_me[x-i] in badchars:
                        strip_me = strip_me[:x-i]
                else:
                        break
        return strip_me


print(clean('aasasdasasdaaaaaaa','asasasasasa'))

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-3 22:02:35 | 显示全部楼层
看着好乱啊
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-5 00:01:44 | 显示全部楼层
重新敲代码,报的错误是 tab和空格使用不一致。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-3-5 02:24:41 | 显示全部楼层
楼上WWCZHC兄弟会的没看懂:sweat:,能不能详细一点。感谢!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-5 16:19:35 | 显示全部楼层
学习了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-6 15:35:32 | 显示全部楼层
你是些类 还是 函数?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-3-6 16:04:24 | 显示全部楼层
是不是 你 导入的genClasses 的模块有问题?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-2-15 00:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表