开发者

python Illegal instruction on AIX5.2

开发者 https://www.devze.com 2022-12-23 17:10 出处:网络
I run my python script functi开发者_高级运维ons like this: read from a text file, and store the data as dict. But when in the loop, an Illegal instruction occurs. why this happens?

I run my python script functi开发者_高级运维ons like this: read from a text file, and store the data as dict. But when in the loop, an Illegal instruction occurs. why this happens? the code is like this:

d={}
datafile=open('a.txt') # a big text file
for line in datafile:
    line=line.rstrip('\n')
    for token in line.split():
        print("Parsing line %d." % token[0])
        d[(int(token[0]))]=token[1:]

then the message is like this:

Parsing line 1.
Parsing line 2.
............
Parsing line 1064
Parsing line 1065
Illegal instruction

what's the problem? my platform is python 2.6.2 on AIX 5.2. please help me, thanks!


This looks very wrong. token is a string in an array of strings returned by line.split(). So token[0] is the first character of that string. Therefore I don't believe that you'll ever get anything like Parsing line 1065 in your output. As Mark wrote, you'd see a TypeError.

Please post

  1. the real code
  2. the real data (an excerpt of the first few lines and line 1065/1066 would suffice)
  3. the real error message.

Otherwise there's no way to help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号