Trending questions in Python

0 votes
1 answer

How do you use a variable in a regular expression?

Instead of using the /regex/g syntax, you can construct ...READ MORE

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

Python: TypeError :Cannot cast Index to dtype int

Try to use numpy  and use .astype(np,int) ...READ MORE

Jun 25, 2020 in Python by Sirajul
• 59,230 points
7,114 views
0 votes
1 answer

How can I safely create a nested directory?

On Python ≥ 3.5, use pathlib.Path.mkdir: from pathlib import ...READ MORE

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

How can I get the domain name of my site within a Django template?

Hello kartik, The variation of the context processor ...READ MORE

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

Error: Syntax Error: Invalid syntax

Indentation error. There should be indent before def ...READ MORE

Oct 7, 2020 in Python by Gitika
• 65,770 points
2,590 views
0 votes
0 answers

hello guys i need help to make this code run plz !

H= float (input("Is this circuit charging& ...READ MORE

Nov 25, 2020 in Python by anonymous
• 120 points
522 views
0 votes
1 answer

Which is the best Python web framework for beginners?

Go for Django . It's easy and ...READ MORE

Nov 18, 2020 in Python by Jayant Kumar
799 views
0 votes
1 answer

How to print prime numbers from 1 to n?

Hello @divyashree def isPrime(n): # ...READ MORE

Oct 13, 2020 in Python by Niroj
• 82,840 points
2,330 views
0 votes
1 answer

How to get the current time in Python?

Use: >>> import datetime >>> datetime.datetime.now() datetime.datetime(2009, 1, 6, 15, ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,770 points
661 views
0 votes
1 answer

How to extract specific tags in multiple html .txt files using python.

Hello, @Pooja, Even I got the same issue, ...READ MORE

Aug 5, 2020 in Python by Kedaar Thomas
5,308 views
0 votes
1 answer

How can I do not equal in Django queryset filtering?

Hello @kartik, You can use Q objects for this. They ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,840 points
791 views
0 votes
1 answer

How to debug Django commands in PyCharm?

Hello @kartik, You can debug a custom Django ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,840 points
4,786 views
0 votes
1 answer

How to overcome “datetime.datetime not JSON serializable”?

Hii @kartik, The simple solution to over come ...READ MORE

Jun 5, 2020 in Python by Niroj
• 82,840 points
7,895 views
0 votes
1 answer

Django: Display a custom error message for admin validation error

Hello @kartik, Without looking, it sounds like the ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,840 points
7,587 views
0 votes
1 answer

Error:Reverse accessor for 'Analysis.assign_user' clashes with reverse accessor for 'Inquiry.assign_user'.

Hello @kartik, The related_name would ensure that the fields were ...READ MORE

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

ModuleNotFoundError: No module named 'turtle'

Hi@akhtar, It seems you don't have the turtle ...READ MORE

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

How do I get the number of elements in a list?

Hello, The len() function can be used with several different ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
661 views
0 votes
1 answer

How are Python metaclasses different from regular class inheritance?

Python 3 class MyClass(object): = New-style class class MyClass: = New-style ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,770 points
535 views
0 votes
1 answer

ImportError: No module named mpmath. But mpmath has been installed.

You should use conda to install Python ...READ MORE

Nov 4, 2020 in Python by Gitika
• 65,770 points
1,255 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pyttsx3' || "Running setup.py install for comtypes ... error" error when installing pyttsx3

Hello, @There It depends on which version of ...READ MORE

Oct 7, 2020 in Python by Gitika
• 65,770 points
2,435 views
0 votes
1 answer

Can't import scikit -learn on python3.

Hi@akhtar, First, remove the Sklearn form your Windows system ...READ MORE

Jun 23, 2020 in Python by MD
• 95,460 points
7,039 views
0 votes
1 answer

How to read a HDF file with Pandas?

Hi@akhtar, You can read an HDF file using ...READ MORE

Oct 18, 2020 in Python by MD
• 95,460 points
1,982 views
0 votes
1 answer

AssertionError: <class 'numpy.ndarray'>

Hi, @There, The traceback module and sys.exc_info are ...READ MORE

Oct 19, 2020 in Python by anonymous
• 65,770 points
1,921 views
0 votes
1 answer

How to run code when a class is subclassed?

Classes (by default) are instances of the ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,770 points
527 views
0 votes
1 answer

Why not inherit from List<T>?

There are some good answers here. I ...READ MORE

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

How to Filter for empty or NULL names in a queryset?

Hello @kartik, You could do this: Name.objects.exclude(alias__isnull=True) If you need ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,840 points
5,095 views
0 votes
1 answer

Error: Can't import matplotlib library.

Install the older version of python, I also ...READ MORE

Nov 6, 2020 in Python by Gitika
• 65,770 points
1,098 views
0 votes
1 answer

How can I create a nested directory?

Hello, Using try except and the right error ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
573 views
0 votes
1 answer

How to call an external command?

Look at the subprocess module in the standard library: import ...READ MORE

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

How to concatenate items in a list to a single string?

Hello @kartik, Use join: >>> sentence = ['this','is','a','sentence'] >>> '-'.join(sentence) 'this-is-a-sentence' Hope it ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,840 points
607 views
0 votes
1 answer

how to send post request to a webpage using cookies and headers in python to scrape the webpage ?

Hey @Avinash, Regarding your query, I would suggest ...READ MORE

Sep 29, 2020 in Python by Roshni
• 10,480 points
2,723 views
0 votes
1 answer

Why do we not follow the "off by one" rule in python

It's because of the way in which ...READ MORE

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

urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

Hi@akhtar, You need to use the read function in ...READ MORE

Jul 15, 2020 in Python by MD
• 95,460 points
6,002 views
0 votes
1 answer

How do I parse XML in Python?

Hello @kartik, You can use BeautifulSoup: from bs4 import BeautifulSoup x="""<foo> ...READ MORE

Nov 19, 2020 in Python by Niroj
• 82,840 points
485 views
0 votes
1 answer

How to call an external command?

Hello @kartik, Look at the subprocess module in the standard ...READ MORE

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

How to get output result from selecting two dropdown menu options in tkinter?

if i choose a value from first ...READ MORE

Sep 4, 2020 in Python by Charitra
• 120 points
3,779 views
0 votes
1 answer

Unable to create a project in django.

I think u didn't install Django. python -m ...READ MORE

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

How do I list all files of a directory?

Hii, Try this: import os os.listdir("somedirectory") Thank you!! ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
481 views
0 votes
1 answer

How to generate a string token using four of this items random?

One approach just generates random integers up ...READ MORE

Nov 16, 2020 in Python by Gitika
• 65,770 points
577 views
0 votes
2 answers

module 'numpy' has no attribute 'unit8'

Hi@Ganesh, I think you are calling the wrong ...READ MORE

Sep 22, 2020 in Python by MD
• 95,460 points
2,875 views
0 votes
1 answer

Deployed Django project on heroku But I don't know which database is it using. Is there a way to know that So that I can login to admin page?

If you don't configure one you might ...READ MORE

Nov 12, 2020 in Python by anonymous
• 65,770 points
704 views
0 votes
1 answer

Error: showing database is locked

ah, sqlite3 stuff... remove .session file and ...READ MORE

Nov 15, 2020 in Python by Sheema
574 views
0 votes
1 answer

How to test multiple variables against a value?

Hello @kartik, Your problem is more easily addressed ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,840 points
484 views
0 votes
1 answer

Sigma code look like this but it’s not working.

Use Markdown to style code: - Use a ...READ MORE

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

Error:Pip install: can't open file pip, or Parent module '' not loaded

Hello @kartik, Assuming you have pip installed and ...READ MORE

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

Tried setting up Django-shop on my system, but when I try to run pipenv install , I get this:404 Snippet not found

Uninstall all python first then install python ...READ MORE

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

How do I pass a variable by reference?

Hello, Just wrap it in a list: def Change(self, ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
417 views
0 votes
1 answer

How to access environment variable values?

Hello @kartik, To check if the key exists ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,840 points
411 views