Monday, 15 March 2010

python/pyfits syntax errors -


I am currently working on some projects using PyFITS. As a beginner with dragon 3.3, I can not understand the two errors ... 1 error ------------------------

  imported pyphis; \ Hdulist = pyfits.open ('/ user / geographical / desktop / test / case.faces') \ i in category (1,26): \ str = hdulist [0] .header [i]; \ Print (str); \ I = i ++; File "& lt; ipython-input-41-651183e88e23" gt; Category (1,26) in Category I: \ ^ SyntaxError: Invalid syntax   

Since I look strange "for" and "before the HDUDULIS = ..." ", Like 3 different inputs in the console instead of 1, I can not find any error ...

Second Error ------- ----------- ----- I try to handle the index error when I get the HDUlevast [0] .reader [I] = none. In my case it is true for i = 26 or more, so I use it except:

  try: \ hdulist [0] .header [30] == None: only : \ Print ("end of header") file "ipython-input-28-fe19468a3999", except for row 3: \ ^ SyntaxError: invalid syntax   

I do not know How will this solve, so if you have any ideas and is enough to help you, thanks! ^^

OK, your syntax is incorrect:

  • Indentation cases
  • With the indentation of each line at the end of the disturbance and eliminating your statements, the backslash needs to go away from them.
  • ; Do not end the statement with , this is Python, no. Statement ends with a new line (which, then, avoids your backslash).

    Then,

      i = i ++;   

    There is not much understanding in any language, but in Python there is no ++ operator and Python to end a statement Do not require a semicolon / for use

    You want

      i + = 1   

    In addition, str Use this as a way to hide the built-in type in this way.

    In addition to this, you should never leave a blank : - Always catch specific exceptions.

    Finally, do not you really want to compare any ? If so, then use

      hdulist [0] .header [30] None # None is a singleton!   

    But everything looks like you should read the original before moving any further.

No comments:

Post a Comment