>>> with open ("Login.txt", "r+", ending= "Utf-8") as F:
... f.readline ()
File "<stdin>", Line 2 f.readline () ^ indentationerror:expected an indented block
Cause: No indentation, add a space or tab to a new line
With open ("Users_info", "RW", encoding= "Utf-8") as F:for line in F:
If "Lisi" in line:
F.seek (F.tell ()-len (line))
Line= "Test 123 0"
F.write (line)
Oserror:telling position disabled by next () call
Why: Tell () cannot be used in a loop, the specific reason needs to be studied in depth
Typeerror:eval () Arg 1 must be a string, bytes or code object
Reason: Use the eval () method on a type that is not a Str,bytes,code object, such as I set a = {"Zhangsan" in Terminal, "123"},eval (a), which is the eval () method for the dictionary, the correct way is a= ' {" Zhangsan "," 123 "} ', Eval (a)
Python module and import appear importerror:no module named ' xxx ' problem
Reason: According to my experience in Java, the import error is because the code is placed under the direction (package), so the import is to add the prefix
For example: If the test.py file is established under module M1, import should be imported M1.test
PEP8 Code Style Error
Expected 2 blank lines, found 0 need two lines blank, 0 rows found
Cause: The file code should be empty two lines behind the comment
Typo:in Word incorrectly spelled
Cause: Word spelling error
variables, values, operators should be preceded by a space, comma should be followed by a space, the output string should be used such as "test%s", the% name, before and after the space
Python Learning Knowledge Base