Trending questions in Python

0 votes
1 answer

Extracting extension from filename in Python

Yes. Use os.path.splitext >>> import os >>> filename, file_extension = ...READ MORE

Nov 27, 2020 in Python by Gitika
• 65,910 points
507 views
0 votes
0 answers

AttributeError: 'numpy.int32' object has no attribute 'map'

can any one suggest solution data['isLarge'] = data.size.map({'small' ...READ MORE

Sep 5, 2020 in Python by Mohammed
• 120 points
4,136 views
0 votes
1 answer

Are static class variables possible in Python?

Variables declared inside the class definition, but ...READ MORE

Nov 30, 2020 in Python by Gitika
• 65,910 points
366 views
0 votes
1 answer

What is the Python 3 equivalent of “python -m SimpleHTTPServer”

The SimpleHTTPServer module has been merged into http.server in Python 3.0. ...READ MORE

Nov 28, 2020 in Python by Gitika
• 65,910 points
476 views
0 votes
1 answer

Error "Failed to load tensorflow runtime"

Hello, Try to downgrade protobuf, this worked for ...READ MORE

Nov 30, 2020 in Python by Niroj
• 82,880 points
375 views
0 votes
0 answers

Why I'm Getting ValueError?

Here is my code: import pandas as p import ...READ MORE

Nov 28, 2020 in Python by Rohan
• 200 points

edited Nov 30, 2020 by Niroj 464 views
0 votes
0 answers

ValueError: could not broadcast input array from shape (224,224,9) into shape (224,224)

img_shape = 224 test_data = [] test_labels = [] for ...READ MORE

Nov 6, 2020 in Python by Eyosiyas
• 120 points
1,430 views
0 votes
1 answer

How to print only the line which starts with P?

Hi, you might have found another way ...READ MORE

Dec 2, 2020 in Python by Tyler
• 140 points
858 views
0 votes
1 answer

How to print without newline or space?

In Python 3, you can use the sep= and end= parameters ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
476 views
+1 vote
1 answer
0 votes
1 answer

How to show Image from Imagefield Django Admin ?

Hello @kartik, In your model class add a ...READ MORE

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

How to enter this command “py -3 -m pip install -r requirements.txt”

Open cmd and type the command and ...READ MORE

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

How to determine whether a substring is in a different string [duplicate]

with in: substring in string: >>> substring = "please help ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
403 views
0 votes
1 answer

ImportError: No module named requests

Hello, To install requests module for Python2: $ sudo apt-get install ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
665 views
0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,210 points
28,772 views
0 votes
1 answer

How can I list txt files into the folder?

Hello @Mziko You can refer this:https://datatofish.com/txt-files-d ...READ MORE

Nov 26, 2020 in Python by Niroj
• 82,880 points
404 views
0 votes
1 answer

You have to print the cheapest item using the dictionary key and values

take input here import ast items=ast.literal_eval(input()) #start writing your code ...READ MORE

Dec 19, 2020 in Python by anonymous
3,338 views
0 votes
1 answer

Does array element contain substring?

Loop through the $forbiddennames array and use stripos to check if ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
381 views
0 votes
1 answer

How to set environment variables in Python?

Hii, Environment variables must be strings, so use os.environ["DEBUSSY"] ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
643 views
0 votes
1 answer

How do I check if a given Python string is a substring of another one?

Try using in like this: >>> x = 'hello' >>> y ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
372 views
0 votes
1 answer

How to create a zip archive of a directory in Python?

Hii, The easiest way is to use shutil.make_archive. It ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
639 views
0 votes
1 answer

How can I generating file to download with Django?

Hello @kartik, To trigger a download you need ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
5,173 views
0 votes
1 answer

How to insert value by one post method in 2 table with Django?

try  import-export   library of Django or if you are ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,910 points
966 views
0 votes
0 answers
0 votes
1 answer

How to convert bytes to a string?

You need to decode the bytes object ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
356 views
0 votes
1 answer

How do I parse XML in Python?

First build an Element instance root from the XML, ...READ MORE

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

How to Test a string for a substring?

if "ABCD" in "xxxxABCDyyyy": ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
354 views
0 votes
1 answer

How do I get a substring of a string in Python?

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> ...READ MORE

Nov 27, 2020 in Python by Gitika
• 65,910 points
349 views
0 votes
0 answers

NameError: name 'genomic_dna_4' is not defined

I use python for biology and I got ...READ MORE

Nov 10, 2020 in Python by skylar
• 120 points
1,078 views
0 votes
1 answer

How can I get a list of locally installed Python modules?

Do not use with pip > 10.0! My ...READ MORE

Nov 26, 2020 in Python by anonymous
• 65,910 points
342 views
0 votes
0 answers

TypeError: tuple indices must be integers or slices, not tuple

Traceback (most recent call last):   File "main.py", line ...READ MORE

Aug 25, 2020 in Python by Peddabudi srikanth
• 120 points
4,396 views
0 votes
1 answer

Calling a function of a module by using its name (a string).

Assuming module foo with method bar: import foo method_to_call = getattr(foo, 'bar') result ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,910 points
403 views
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,910 points
323 views
0 votes
1 answer

Error:UnicodeDecodeError when reading CSV file in Pandas with Python

Hello @kartik, Try this: import pandas as pd df = ...READ MORE

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

ModuleNotFoundError: No module named 'pytest'

Hi@akhtar, You need to install pytest module in ...READ MORE

Jun 24, 2020 in Python by MD
• 95,440 points
7,033 views
0 votes
1 answer

Test Failed: unsupported operand type(s) for -: 'tuple' and 'list'

Hi, @There, Check what are you passing.. the ...READ MORE

Oct 5, 2020 in Python by Gitika
• 65,910 points
2,658 views
0 votes
1 answer

Does Python have a string 'contains' substring method?

You can use the in operator: if "blah" not in ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
302 views
0 votes
1 answer

AttributeError: 'NoneType' object has no attribute 'find'

Hi@akhtar, It seems Sklearn is not installed properly ...READ MORE

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

How to generate all permutations of a list?

Hello @kartik, Try this: def permutations(head, tail=''): ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
681 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,910 points
361 views
0 votes
1 answer

How can I install pip on Windows?

Python 2.7.9+ and 3.4+ Python 3.4 (released March 2014) ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
439 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
345 views
0 votes
2 answers

Is Python fully object oriented?

Python supports all the concept of "object ...READ MORE

Sep 13, 2020 in Python by Anjali Chauhan
17,545 views
0 votes
1 answer

How to access the user profile in a Django template?

Hello @kartik, In your profile model provide related_name user ...READ MORE

Jul 29, 2020 in Python by Niroj
• 82,880 points
5,390 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
566 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,910 points
443 views
0 votes
1 answer

Help please on basic python web server

Hi, @There, The error is because there is ...READ MORE

Oct 27, 2020 in Python by Gitika
• 65,910 points
1,520 views
0 votes
1 answer

Error:Unresolved reference 'django' error in PyCharm

Hello @kartik, I assume you're using a virtualenv ...READ MORE

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

pytest: error: unrecognized arguments: --html=basic.html

Hi@akhtar, You have to install one module named ...READ MORE

Jun 24, 2020 in Python by MD
• 95,440 points
6,879 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,880 points
2,081 views