Trending questions in Python

0 votes
1 answer

How to update date automatically after a value change in django?

Hello @kartik, Only change your pub_date if published has ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,840 points
9,674 views
0 votes
1 answer

Error: current transaction is aborted, commands ignored until end of transaction block?

Hii kartik, To get rid of the error, roll ...READ MORE

Apr 23, 2020 in Python by Niroj
• 82,840 points
12,642 views
0 votes
1 answer

SELENIUM ERROR !!HELP!!

Hi, @There, A possibility is that the element ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,542 views
0 votes
1 answer

Error:AttributeError: 'NoneType' object has no attribute 'extend'

Hello @kartik, You can use itertools.chain(): import itertools list2d = [[1,2,3], ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
3,569 views
0 votes
0 answers

ValueError: not enough values to unpack (expected 2, got 0)

I want to load the NSL_KDD data ...READ MORE

May 9, 2020 in Python by arezoo
• 220 points

edited May 13, 2020 by Gitika 11,919 views
0 votes
1 answer

How to install pip with Python 3?

If you're running Python 2.7.9+ or Python ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,467 views
0 votes
1 answer

Error: No module named psycopg2.extensions

Hello @kartik, The first thing to do is ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
7,562 views
+1 vote
1 answer

How to validate a field on update in DRF?

Hello @kartik, You can definitely do this using ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,840 points
9,513 views
0 votes
1 answer

ValueError: must have exactly one of create/read/write/append mode

You can open a file for simultaneous ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,770 points
3,622 views
0 votes
1 answer

Error:Python NameError: name 'include' is not defined

Hello @kartik, On the basis of your information provided ...READ MORE

Jul 1, 2020 in Python by Niroj
• 82,840 points
9,519 views
0 votes
1 answer

Import Error: No module named numpy?

Hello, I had numpy installed on the same ...READ MORE

Apr 14, 2020 in Python by Niroj
• 82,840 points
12,837 views
0 votes
1 answer

How to declare an array in Python?

variable = [] Now variable refers to an empty list*. Of ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,302 views
0 votes
1 answer

How do I find the a referring sites URL in node?

Hii, In express 4.x: req.get('Referrer') This will also check both spellings of ...READ MORE

Nov 27, 2020 in Python by Niroj
• 82,840 points
2,977 views
0 votes
1 answer

How to terminate a python script?

This can be done by importing the ...READ MORE

Aug 9, 2019 in Python by Arvind
• 3,050 points
23,529 views
+1 vote
1 answer

ImportError: DLL load failed: The specified module could not be found.

Hi@akhtar, You may get this error if you ...READ MORE

Jun 22, 2020 in Python by MD
• 95,460 points
9,725 views
0 votes
1 answer

Error when running pip install: python setup.py egg_info"

ERROR: Command errored out with exit status ...READ MORE

Oct 29, 2020 in Python by anonymous
5,029 views
0 votes
1 answer

How to drop all tables from the database with manage.py CLI in Django?

Hello @kartik, Python you can write your own ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,840 points
7,737 views
0 votes
1 answer

Is it possible to break a long line to multiple lines in Python?

Example of implicit line continuation: a = some_function( ...READ MORE

Jan 4, 2021 in Python by Gitika
• 65,770 points
1,232 views
0 votes
1 answer

How can I safely create a nested directory?

Python 3.5+: import pathlib pathlib.Path('/my/directory').mkdir(parents=True, exist_ok=True) pathlib.Path.mkdir as used above ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,770 points
3,249 views
0 votes
1 answer

ImportError: Import by filename is not supported

Instead of doing a import like __import__ you can ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
2,868 views
0 votes
1 answer

How to match all occurrences of a regex?

Using scan should do the trick: string.scan(/regex/) READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
2,932 views
0 votes
1 answer

How to update user password in Django Rest Framework?

Hello @kartik, Using a modelserializer might be an ...READ MORE

Jul 1, 2020 in Python by Niroj
• 82,840 points
9,238 views
0 votes
1 answer

How to store a dictionary on a Django Model?

Hello @kartik, If you don't need to query ...READ MORE

Jun 29, 2020 in Python by Niroj
• 82,840 points
9,325 views
0 votes
1 answer

Call a function from another file?

There isn't any need to add file.py while importing. ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
1,112 views
+1 vote
3 answers

While using pyttsx 3 , I am having the following ERROR, i have installed pypiwin32

Try this: pip uninstall pyttsx3 Then: pip install pyttsx3==2.71 READ MORE

Aug 12, 2020 in Python by Eghosa
7,956 views
0 votes
1 answer

How can I return HTTP status code 204 from a Django view?

Hello, Try this: return HttpResponse(status=204) Hope it works!! ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
7,181 views
0 votes
3 answers

How to split a string into a list?

Using For loop This approach uses for loop ...READ MORE

Jan 4, 2021 in Python by David Samon
1,018 views
0 votes
1 answer

AttributeError: 'Group' object has no attribute 'user'

You can go through this: from django.contrib.auth.models import ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,770 points
3,372 views
0 votes
1 answer

Error: Failed building wheel for MySql-Python

Hello @kartik, You need to install the following ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,840 points
9,114 views
0 votes
3 answers

How to add a new item to a dictionary in Python?

There is no add() , append() , or insert() method ...READ MORE

Jan 4, 2021 in Python by Reshma
963 views
0 votes
1 answer

How to create a GUID/UUID in Python?

Hello @kartiK, If you need to pass UUID ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,840 points
2,193 views
0 votes
1 answer

How to get the position of a character in Python?

There are two string methods for this, find() and index(). ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
991 views
0 votes
1 answer

How to get value from form field in django framework?

Hello @kartik, Using a form in a view can ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,840 points
9,132 views
0 votes
1 answer

ERROR: Could not build wheels for line-profiler which use PEP 517 and cannot be installed directly.

Hi@akhtar, If you are trying to install with pip ...READ MORE

Nov 5, 2020 in Python by MD
• 95,460 points
3,589 views
0 votes
1 answer

How to Remove specific characters from a string in Python?

Strings in Python are immutable (can't be changed). Because ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,770 points
951 views
0 votes
1 answer

How to find the occurrences of any word with more than two vowels in a file using regex?

for word in read: <--- iterating ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
2,724 views
0 votes
1 answer

What is the equivalent of “none” in django templates?

Hello @kartik, None, False and True all are available ...READ MORE

Jul 3, 2020 in Python by Niroj
• 82,840 points
8,908 views
0 votes
3 answers

How can I sort a dictionary by key in python?

Another way could be: color_dict = {'red':'#FF0000',           'green':'#008000',           'black':'#000000',           'white':'#FFFFFF'} for ...READ MORE

Dec 28, 2020 in Python by Thomas Walenta
1,105 views
0 votes
1 answer

What does request.user refer to in Django?

Hello @kartik, request.user is User model object. You cannot access ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,840 points
9,307 views
0 votes
1 answer

Adding new column to existing DataFrame in Python pandas

Use the original df1 indexes to create ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,770 points
1,395 views
0 votes
1 answer

ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

Hi, @Henll, You should download the version that ...READ MORE

Oct 22, 2020 in Python by Gitika
• 65,770 points
4,070 views
0 votes
1 answer

ModuleNotFoundError: No module named 'bs4'

Hi@akhtar, You need to install the bs4 package ...READ MORE

Jun 26, 2020 in Python by MD
• 95,460 points
9,165 views
0 votes
1 answer

Error: IndexError: list index out of range and python

IndexError The IndexError is raised when you attempt to retrieve ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,770 points
1,688 views
0 votes
0 answers

How to write df to excel without attribute error, and how to add 2 header columns (1 header, 1 units)

Hi, I am very new to Python ...READ MORE

Jun 3, 2020 in Python by Edureka
• 120 points

edited Jun 5, 2020 by Gitika 10,193 views
0 votes
1 answer

What will be the output of below code and why? x=[1,2,3,4,5] print(x.insert(2,3))

If you write x.insert(2,3) and then print x ...READ MORE

Oct 14, 2020 in Python by Gitika
• 65,770 points
4,361 views
0 votes
1 answer

ModuleNotFoundError: No module named 'cv2'

Check if it's installed properly, It will work ...READ MORE

Oct 12, 2020 in Python by Gitika
• 65,770 points
4,432 views
0 votes
0 answers

can't compare offset-naive and offset-aware datetimes

While I'm Trying to Compare Two dates ...READ MORE

Dec 12, 2020 in Python by Mohamed
• 170 points
1,810 views
0 votes
1 answer

How to import a module given the full path?

For Python 3.5+ use: import importlib.util spec = importlib.util.spec_from_file_location("module.name", ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
2,526 views
0 votes
1 answer

What is the difference between driver.close() and driver.quit()?

They do a similar thing but not ...READ MORE

Apr 6, 2019 in Python by Yash
28,389 views