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,880 points
9,055 views
0 votes
1 answer

Distance calculator

Hello @ Try this code: import math x, y = ...READ MORE

Nov 13, 2020 in Python by Niroj
• 82,880 points
3,246 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,910 points
990 views
0 votes
1 answer

How do I add a link from the Django admin page of one object to the admin page of a related object?

Hello @kartik, Set show_change_link to True (False by default) in your inline ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,880 points
9,885 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,910 points
941 views
0 votes
1 answer

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

Apr 27, 2020 in Python by MD
• 95,440 points
12,728 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,910 points
2,710 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,880 points
2,979 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,910 points
3,089 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,440 points
9,343 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
4,639 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,880 points
11,961 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,880 points
12,346 views
0 votes
1 answer

Python: ImportError: No module named Crypto.Cipher

Seems like the pycrypto package is not ...READ MORE

Jul 31, 2019 in Python by Hari
23,446 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,910 points
778 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
682 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,910 points
2,438 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,880 points
7,226 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,910 points
3,029 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,910 points
661 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,880 points
8,730 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
567 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,910 points
2,401 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,910 points
2,664 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,910 points
1,457 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,910 points
1,137 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,880 points
8,775 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
811 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,880 points
2,219 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,880 points
8,597 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,580 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,440 points
3,097 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,880 points
1,663 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,880 points
8,596 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,440 points
8,768 views
0 votes
1 answer

Install a Python package into a different directory using pip?

Use: pip install --install-option="--prefix=$PREFIX_PATH" package_name You might also want ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,910 points
1,847 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,910 points
4,090 views
0 votes
1 answer

How to print colored text in Python?

This somewhat depends on what platform you ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,910 points
1,225 views
0 votes
0 answers

joining two images reading from one folder

Hi, i am trying to generating joined ...READ MORE

Jan 3, 2021 in Python by shapna
• 120 points
524 views
0 votes
1 answer

Remove final character from string

Simple: st = "abcdefghij" st = st[:-1] There is ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,910 points
388 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,910 points
3,588 views
0 votes
0 answers

AttributeError: 'Index' object has no attribute 'get_values'

parameters = pd.read_csv(params_filename, sep="\t") free_parameters = parameters.columns.get_values().to_list() free_parameters = ...READ MORE

Sep 7, 2020 in Python by Swastik
• 120 points
5,541 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,880 points
8,451 views
0 votes
1 answer

Error: Unhandled exception in thread started by Error in sys.excepthook:

I think the general idea of the ...READ MORE

Nov 2, 2020 in Python by Gitika
• 65,910 points
3,037 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,040 points
22,515 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
27,942 views
0 votes
1 answer

Error in jarvis project (get url)

Hey, @Zodarlxx, Could you please post your error ...READ MORE

Dec 30, 2020 in Python by Gitika
• 65,910 points
524 views
0 votes
3 answers

Is there a simple way to delete a list element by value?

There are three ways in which you ...READ MORE

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

Why is reading lines from stdin much slower in C++ than Python?

tl;dr: Because of different default settings in ...READ MORE

Dec 18, 2020 in Python by Nikita
994 views
0 votes
1 answer

How can I use Python to get the system hostname?

Hello @Kartik, Use socket and its gethostname() functionality. This will get the hostname of ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
1,420 views