Most viewed questions in Python

0 votes
1 answer

Why can't Python parse this JSON data?

Your data is not a valid JSON format. You ...READ MORE

Dec 20, 2020 in Python by Reshma
8,544 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,544 views
0 votes
1 answer

Python error "ZeroDivisionError: division by zero"

Catch the error and handle it: try: ...READ MORE

May 31, 2019 in Python by Rhea
8,503 views
0 votes
1 answer

How to list a column of float values from csv file without importing (Python)

Using the default CSV module Demo: import csv with open(filename, "r") ...READ MORE

Sep 16, 2020 in Python by Rajiv
• 8,910 points
8,485 views
0 votes
1 answer

Install python using Ansible

Try something like: - hosts: all remote_user: ...READ MORE

Jul 22, 2019 in Python by Travis
8,452 views
0 votes
1 answer

How can I disable logging while running unit tests in Python Django?

Hello @kartik, Since you are in Django, you ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,880 points
8,435 views
0 votes
1 answer

'foreach' function in Python 3?

Yes, there is a "foreach" in python. ...READ MORE

Oct 24, 2018 in Python by Priyaj
• 58,090 points
8,411 views
0 votes
2 answers

How do I convert text file to CSV file with only plain python. Meaning no panda or any other special module?

Steps to Convert Text File to CSV ...READ MORE

Oct 15, 2020 in Python by Abdul Shekh
8,400 views
0 votes
1 answer

Dictionary in NumPy array

You have a 0-dimensional array of object ...READ MORE

Jan 18, 2019 in Python by SDeb
• 13,300 points
8,363 views
0 votes
1 answer

Open multiple files using with open() in Python?

Just replace and with , and you're done: with open('a', 'w') as ...READ MORE

Oct 31, 2018 in Python by Priyaj
• 58,090 points
8,348 views
0 votes
1 answer

ValueError: could not convert string to float: id

The problem is that in your code ...READ MORE

Apr 28, 2022 in Python by narikkadan
• 63,620 points
8,321 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,880 points
8,287 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,880 points
8,179 views
+1 vote
2 answers

python nmap can't find PortScanner attribute

you want install        1.pip uninstall nmap        2.pip install python-nmap in ...READ MORE

Jan 25, 2020 in Python by Rangertech_hacker234
8,152 views
0 votes
1 answer

Error:'pip' is not recognized as an internal or external command

Hello @kartik, Try this: Type 'start %appdata%' in cmd. After ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,880 points
8,114 views
0 votes
1 answer

How to send a correct authorization header for basic authentication

Hello @kartik, Here is how to do Basic ...READ MORE

Aug 13, 2020 in Python by Niroj
• 82,880 points
8,113 views
0 votes
1 answer

Explain split() and join() functions in Python?

Hey, @Roshni, You can use split() function to split a ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,910 points
8,101 views
0 votes
1 answer

How Do You Run A Python Script In Blender?

Blender is a free and open-source 3D ...READ MORE

Jul 30, 2019 in Python by Mohammad
• 3,230 points
8,087 views
0 votes
1 answer

Python error "SyntaxError: invalid syntax"

but i m getting this ouput: Enter the ...READ MORE

Mar 20, 2020 in Python by anonymous
8,075 views
0 votes
0 answers

AttributeError: 'DataFrame' object has no attribute 'is_impossible'

from collections import Counter import re import numpy as ...READ MORE

Mar 10, 2020 in Python by Mohammed
• 120 points

edited Mar 11, 2020 by Gitika 8,060 views
0 votes
1 answer

How to install openssl in python?

pip install openssl-python run this command in the ...READ MORE

Aug 2, 2019 in Python by Mohammad
• 3,230 points
8,047 views
–1 vote
1 answer

How to get the current URL within a Django template?

Hello @kartik, You can fetch the URL in ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
8,034 views
0 votes
1 answer

Can't Click an Element in Python Selenium After Successfully Finding It

I've encountered this problem of not being ...READ MORE

Oct 4, 2018 in Python by Priyaj
• 58,090 points
7,935 views
0 votes
1 answer

ImportError: cannot import name 'render_to_response' from 'django.shortcuts'

Hello @kartik, The render_to_response shortcut was deprecated in Django 2.0, and ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
7,923 views
0 votes
1 answer

Need a python script to login into a website but username and password are in a txt file (Selenium automation script)

I had a similar requirement. I had ...READ MORE

Jan 31, 2019 in Python by Omkar
• 69,230 points
7,921 views
0 votes
1 answer

what is a constructor in python?

Constructors are for instantiating an object.The task ...READ MORE

Apr 1, 2019 in Python by Tushar
• 200 points
7,907 views
0 votes
1 answer

Rename a key in dict

dictionary[new_key] = dictionary.pop(old_key) READ MORE

Jun 8, 2018 in Python by Hamartia's Mask
• 1,580 points
7,864 views
0 votes
2 answers

How do I set the figure title and axes labels font size in Matplotlib?

Setting the font size of the figure ...READ MORE

Jan 4, 2021 in Python by Nikita
7,849 views
0 votes
1 answer

USING LIKE inside pandas.query()

If you have to use df.query(), the ...READ MORE

Jul 22, 2019 in Python by SDeb
• 13,300 points
7,821 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pymongo'

Hi@akhtar, It seems you don't have a Pymongo module ...READ MORE

Jun 26, 2020 in Python by MD
• 95,440 points
7,806 views
+5 votes
0 answers

How to send sms to users from Django application?

I'm looking for an option to send ...READ MORE

Nov 13, 2018 in Python by Manu
• 170 points
7,780 views
+1 vote
1 answer

'numpy.ndarray' object has no attribute 'append'

Hi@Noman, You created two empty list. And in ...READ MORE

May 17, 2020 in Python by MD
• 95,440 points
7,768 views
0 votes
1 answer

SyntaxError: Missing parentheses in call to "print".

The statement print "hello python" does not work in ...READ MORE

Jul 16, 2019 in Python by Umar
7,763 views
0 votes
1 answer

How to use read a WSDL file from the file system using Python suds?

Hi, good question. It is a very simple ...READ MORE

Jan 21, 2019 in Python by Nymeria
• 3,560 points
7,740 views
0 votes
1 answer

How to get the SQL from a Django QuerySet?

Hello @kartik, Try this in your queryset: print my_queryset.query For ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,880 points
7,735 views
0 votes
1 answer

Python: For loop to iterate class object

Refer to the below code: class Try: ...READ MORE

May 22, 2019 in Python by Raj
7,724 views
+1 vote
1 answer

How do I find out the sum of digits of a number in Python?

Hi, good question. If you are considering ...READ MORE

Feb 7, 2019 in Python by Nymeria
• 3,560 points
7,717 views
0 votes
1 answer

Python error "TypeError: Cannot compare types 'ndarray(dtype=int64)' and 'str'"

Hey @Ashish, change the emotion_map to the ...READ MORE

May 30, 2019 in Python by Mir
7,707 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

Aug 5, 2018 in Python by Omkar
• 69,230 points

edited Aug 8, 2018 by Omkar 7,698 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,880 points
7,681 views
0 votes
1 answer

How to insert a date into MySQL using Python?

Hi@akhtar, You can use the DateTime module to insert a date into ...READ MORE

Jul 15, 2020 in Python by MD
• 95,440 points
7,677 views
0 votes
1 answer

Error:Expected view to be called with a URL keyword argument named “pk”

Hello @kartik, View functions are called with the ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,880 points
7,666 views
0 votes
1 answer

How to get value in Pandas dataframe using index?

You can use the iloc method to do ...READ MORE

Apr 8, 2019 in Python by Rohit
7,653 views
0 votes
1 answer

How to get absolute path in python?

Instead of using os.path.dirname method which returns the relative ...READ MORE

Feb 4, 2019 in Python by Omkar
• 69,230 points
7,601 views
+1 vote
1 answer

Python pip: “error: Microsoft Visual C++ 14.0 is required”

Seems like the setup tools for python ...READ MORE

Aug 20, 2019 in Python by Kunal
7,599 views
0 votes
1 answer
0 votes
2 answers

This kind of error throwing AttributeError: __enter__

I had recently found its solution and ...READ MORE

Jul 31, 2020 in Python by lokesh
7,530 views
0 votes
1 answer

Replace NaN in rolling mean in python

Try this: In [92]: ts.rolling(window=2, min_periods=1).mean() Out[92]: ...READ MORE

Sep 27, 2018 in Python by Priyaj
• 58,090 points
7,513 views
0 votes
1 answer

Copy constructor vs constructor

Constructor: It is a method which has the ...READ MORE

Aug 14, 2019 in Python by Wajiha
• 1,950 points
7,508 views
0 votes
1 answer

How can I make Python's UnitTest Framework fail if an exception is raised by any thread?

I've come across this problem myself, and ...READ MORE

Dec 5, 2018 in Python by aryya
• 7,450 points
7,499 views