[Tutor] 回复: help for the code debug

Alan Gauld alan.gauld at yahoo.co.uk
Mon Oct 5 05:09:20 EDT 2020


On 05/10/2020 09:23, Sailormoon wrote:
> Dear  Mr Alan :
> I changed The data format of The excel ,as attached ,


As I suspected your problem is that you are using eval()

You pass eval() a value from your spreadsheet which looks like

'HFY3-3720-STR-RFI-0032'

And python sees that as a line of code and tries to subtract 0032 from
something called RFI.

But 0032 is not a valid number literal in python, so you get an error.

Until you fix the data formatting problem the rest of your code has no
chance
of working as you expect. If it does it will be a lucky accident!

Incidentally the tutor list does not accept binary attachments like
screenshots
or excel files,  I only see it because you CC'd me directly.


But if you had included the full error message we would have seen
something like:

>>> eval('HFY3-3720-STR-RFI-0032')
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    eval('HFY3-3720-STR-RFI-0032')
  File "<string>", line 1
    HFY3-3720-STR-RFI-0032
                         ^
SyntaxError: leading zeros in decimal integer literals are not
permitted; use an 0o prefix for octal integers


Which would have shown us exactly what the data error was.
That's why it is important to include the complete error message.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list