Python scripting issues set

1、indentationError:expected an indented block

Indent module inconsistency problem

 

2、AttributeError: ‘module’ object has no attribute’xxx’

This is actually a problem .pyc file:

identify the problem:

View the source file import libraries, files and .pyc found no errors exist in the source file source file

Problem Solution:

1). When naming py script, do the same with the reserved word python, module names, etc.

2) to delete the library .pyc file (as will generate .pyc py script file for each run; in the case of .pyc file has been generated, if the code is not updated, the runtime will still go pyc, so you want to delete .pyc files), re-run the code; or operating environment can find a code to replace the current copy of the file to the machine .pyc)

3, why some parameters need to be defined in advance, and some not? No, all we need to have an equal sign (=) assignment, but there will be some other actions before the assignment, but is not able to equate the province.

Why can not even equate it? Otherwise it can not be judged? As if a == b == c, can not at this time the inspection of a == c.

 

4, IndexError: list index out of range: not match the length of the list, can not be compared

 

5, typeerror: 'list'object is not callable: represents the list can not be invoked, usually written in error

 

6, indexerror: list assignment index out of range: list [index] index is out of range; list is empty, no element, a list [0] will be the error

 

7, indentationerror: unindent does not match any outer indentation level: indentation is not uniform

 

8, typeerror: xxx take exactly 2 arguments (3 given): the method takes two parameters, you pass three

 

9, dictionary items () and iteritems () function is invoked format standard format and other functions are the same: variable method ()

 

10, Python dictionary (Dictionary) dirt.keys () function to return a list of all the keys dictionary

 

11: AttributeError: AttributeError: 'xxx' object has no attribute 'xxx' - suggesting that the property does not exist, focus on understanding its configuration if there are problems.

 

12:pymongo.errors.duplicatekeyerror e11000 duplicate key error collection

The reason: _id can not be repeated, clear the contents of the database to solve.

 

13、TypeError: sequence item 4: expected string or Unicode, NoneType found

The reason: automated script msg return null type of data, resulting in this error, post-classification processing solutions.

 

14、/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.

SNIMissingWarning

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.

InsecurePlatformWarning

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.

InsecurePlatformWarning。。。

The reason: Because SSL issues, urllib3 need pyopenssl; this problem often encountered in older Python, it is estimated more difficult to control in BAE, the seemingly only way requirements.txt installation.

pip urllib3 use this library when https install the module from the source, before the older python2.7.9 ssl module, cause security problems of some SSL connections [1]. Directly addresses this problem in two ways:

  1. Python upgrade to 2.7.9 above
  2. Install security depends urllib3 [2]

>> pip install pyopenssl ndg-httpsclient pyasn1

 

 

 

Released seven original articles · won praise 0 · Views 133

Guess you like

Origin blog.csdn.net/fasddf/article/details/103422099