小编Mic*_*ael的帖子

Python字符串赋值问题!

所以我对Python很新,但我完全不知道为什么这个强大的oldUser在我进行解析调用之后会改变为当前用户.任何帮助将不胜感激.

while a < 20:
    f = urllib.urlopen("SITE")
    a = a+1

    for i, line in enumerate(f):
        if i == 187:
            print line

            myparser.parse(line)
            if fCheck == 1:
                result  = oldUser[0] is oldUser[1]
                print oldUser[0]
                print oldUser[1]
            else:
                result = user is oldUser

            fCheck = 1
            print result

            user = myparser.get_descriptions(firstCheck)

            firstCheck = 1
            print user

            if result:
                print "SAME"
                array[index+1] = array[index+1] +0
            else:
                oldUser = user

        elif i > 200:
            break
        myparser.reset()
Run Code Online (Sandbox Code Playgroud)

我不明白为什么结果也不起作用......我打印出两个值,当它们相同时它告诉我它们不相等......另外,为什么myparser.parse(line)变成oldUser变成2号阵列?谢谢!

**这是myparse的定义......

class MyParser(sgmllib.SGMLParser):
"A simple parser …
Run Code Online (Sandbox Code Playgroud)

python string parsing variable-assignment

1
推荐指数
1
解决办法
695
查看次数

标签 统计

parsing ×1

python ×1

string ×1

variable-assignment ×1