Python _ problem record summary and python record summary

Source: Internet
Author: User

Python _ problem record summary and python record summary

Python IndentationError: unindent does not match any outer indentation level problem

Compile a job in python. I first used notepad ++ to edit the job. Then I went back to bed and used pycharm to edit it. This problem occurred when I wrote a function test, in fact, it is a matter of indentation, because the newline of notepad ++ uses spaces, while the tab is used after pycharm is Indented by line breaks, so there is a problem with indentation, it took me a long time to find out that was the case. It was annoying !!! IndentationError: expected an indented block. This is also a similar error. You can change the indentation to a unified tab or space. ============== ========================================================== ========== Python SyntaxError: Non-ASCII character '\ xe8' in fileImport matffe _ name _ = '_ main _': name1 = raw_input ("Enter your ID:") print name1 complete error message: file "D: \ python \ pythons \ src \ test. py ", line 20 SyntaxError: Non-ASCII character '\ xe8' in file D: \ python \ pythons \ src \ test. py on line 20, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details missing encoding type declaration: no encoding declared modified as follows: a # encoding: utf-8import matlif _ name _ = '_ main _': name1 = ra W_input ("Enter your ID:") print name1. The red part is the encoding declaration! The following statement can be used: # coding: UTF-8: you can change to ==================================================== ========================================================== = RuntimeError: maximum recursion depth exceeded recursive depth ErrorI checked on the Internet and found that the default recursive depth of python is very limited, probably more than 900. When the recursive depth exceeds this value, this exception will be thrown. By default, Python has a limit on the available recursive depth to avoid exhausting the memory in the computer. On my computer, this is 1000. The solution is to manually set the recursive call depth:
Import syssys. setrecursionlimit (1000000) # For example, set it to 1 million

 


How to Learn about Python

C ++, Java, and even C # can all be seen as the same type of language: C ++ is flexible, but complicated syntax makes production efficiency low, and Java improves production efficiency, however, flexibility is lost. C # is a good balance between production efficiency and flexibility, but it is still not enough. Otherwise, the father of Boo language will not be angry with Boo. Python is a dynamic type and a strong type language. A dynamic type means that you no longer need to make numerous declarations for the type of each variable, because the compiler will help you make type judgments, it will determine the type of the Variable Based on the Value assignment of the variable. A strong type means that you cannot use a string as an int unless you explicitly convert it. Python itself is compact, because space is ignored in C ++, Java, C #, and "{}" to define code blocks, if you like it, you can write all the code on one line, so you can write it as dizzy as possible. It is not possible, because there is only one Separator in it, namely the colon ":", and the code block is distinguished by indentation. Maybe you will be a bit unaccustomed to this method at the beginning, but later, you will find that this method will benefit you a lot, because you have developed a good code style. Don't think that Python is a very academic language, although many people think it is very suitable as an entry-level language for learning programming. In fact, Python is not only suitable for beginners to learn programming, but also a powerful language. You can use it to do anything other languages can do. Python itself is almost everywhere, and programs written in Python can run in various mainstream operating systems, even Palm. Oh, I almost forgot. Eric Raymond also told us that hackers must master four languages. The first step is Python ., Of course, if you cannot leave. NET in a day, you should start learning Python from IronPython. Compared with C ++, Java, and even C #, is it much faster to write and execute this classic program in Python? Haha ~~~ If I make up my mind to say that Python is highly productive, you will already scold me for being a lie. Okay. Let's try some practical code. But before that, you have to download two very famous class libraries: wxPython and Twisted. Is the download and Installation complete? Let's start our tour of EnjoyPythonwith you in ten minutes. FromwxPython. wximportwxPySimpleApp, wxFrameapp = wxPySimpleApp () frame = wxFrame (None,-1, "HelloWorld ")

A problem about retrieving strings in Python

Hello, the following is a summary of the common Python Regular Expression usage:
# Conclusion # ^ match the start of a string. ##$ Match the end of a string. # \ B matches the boundary of a word. # \ D match any number. # \ D match any non-numeric characters. # X? Match an Optional x character (in other words, it matches 1 or 0 x characters ). # X * matches 0 or multiple x characters. # X + matches x characters once or multiple times. # X {n, m} matches x characters, at least n times, at most m times. # (A | B | c) either matches a, B, or c. # (X) indicates a remembered group ). You can use the re. search function to return the value of the # image groups () function. # Vertices in regular expressions usually mean "matching any single character"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.