Trending questions in Python

0 votes
1 answer

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

Hi@Nilesh, You have created two empty lists. And ...READ MORE

Aug 11, 2020 in Python by MD
• 95,460 points
6,379 views
0 votes
1 answer

how easy is yaml to work with in python compared to json?

Hi, First thing YAML and JSON are not ...READ MORE

Dec 16, 2020 in Python by MD
• 95,460 points
864 views
0 votes
1 answer

how can I save my output of xml parsing in excel file...?

Hi, @Arjmand, I would suggest you go through ...READ MORE

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

HI Mr / Mrs I have problem with my jupiter notebook when i try to learn Your video about Machine Learning. Can You help me please ?

Hi@Herlambang, I think you have a 32-bit system. ...READ MORE

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

When i try to install os_sys i get an error when installing backend dependencies

pip install -U os-sys READ MORE

Oct 16, 2020 in Python by anonymous
3,967 views
0 votes
1 answer

How do I remove/delete a folder that is not empty?

import shutil shutil.rmtree('/folder_name') By design, rmtree fails on folder trees containing ...READ MORE

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

i want to ask that how can i run one file of python in another file in jupyter notebook

motion_detection.ipynb # Python program to implement # Webcam Motion ...READ MORE

Dec 16, 2020 in Python by Ramsha
• 120 points
840 views
0 votes
1 answer

How can I count the occurrences of a list item?

If you only want one item's count, ...READ MORE

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

How can I print literal curly-brace characters in python string and also use .format on it?

You need to double the {{ and }}: >>> x = ...READ MORE

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

How do I check whether a file exists without exceptions?

 It's safer to use a try around the attempt ...READ MORE

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

How to pad zeroes to a string?

Strings: >>> n = '4' >>> print(n.zfill(3)) 004 And for numbers: >>> ...READ MORE

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

Accessing the index in 'for' loops?

Using an additional state variable, such as ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,770 points
720 views
+1 vote
2 answers

Error:Django gives Bad Request (400) when DEBUG = False

Tried this and it resolved all my ...READ MORE

Sep 25, 2020 in Python by Agaba
6,210 views
0 votes
1 answer

Installing PIL with pip

Install Xcode and Xcode Command Line Tools ...READ MORE

Sep 11, 2020 in Python by FogleBird
4,845 views
0 votes
1 answer

Speed up millions of regex replacements in Python 3

One thing you can try is to ...READ MORE

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

Meaning of @classmethod and @staticmethod for beginner?

Example class Date(object): def __init__(self, ...READ MORE

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

How to invoke a python static method inside class via string method name?

Use __import__ function to import the module by giving ...READ MORE

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

Getting the class name of an instance?

Have you tried the __name__ attribute of the class? ie type(x).__name__ will ...READ MORE

Dec 20, 2020 in Python by Gitika
• 65,770 points
513 views
0 votes
2 answers

How can I safely create a nested directory?

No need to put filename.txt For directory check path ...READ MORE

Nov 25, 2020 in Python by Deepak Chaurasia
1,637 views
0 votes
1 answer

How to get all links and all elements that are clickable on a page of system dynamically?

Hello, You can do it by using find_elements_by_xpath() driver ...READ MORE

Aug 27, 2020 in Python by Niroj
• 82,840 points
5,450 views
0 votes
0 answers

how to solve this

from nsepy import get_history from datetime import date import ...READ MORE

Dec 12, 2020 in Python by Pawan
• 120 points
891 views
0 votes
1 answer

How can I add new keys to a dictionary?

d = {'key': 'value'} print(d) # {'key': 'value'} d['mynewkey'] = ...READ MORE

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

Python code for motion detection

Hey, @Sushruth, Here the code goes for Motion Detector.py import ...READ MORE

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

How to find local IP addresses using Python's stdlib?

Hello @kartik, Try this out: import socket s = socket.socket(socket.AF_INET, ...READ MORE

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

ValueError: arrays must all be same length

Hello, For your query you can refer this:https://www.programmersought.com/article/5321489391/ Hope ...READ MORE

Sep 21, 2020 in Python by Niroj
• 82,840 points
4,362 views
+1 vote
1 answer

Can anyone help me with this error: TypeError: list indices must be integers or slices, not str

Hi, @Varshap  It’s a TypeError, which tells us ...READ MORE

Nov 5, 2020 in Python by anonymous
• 65,770 points
2,359 views
0 votes
1 answer

How to get the home directory in Python?

Hello, You need to use os.path.expanduser. This will ensure it works ...READ MORE

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

How to delete a file or folder?

os.remove() removes a file. os.rmdir() removes an empty directory. shutil.rmtree() deletes a ...READ MORE

Dec 17, 2020 in Python by Nikita
556 views
0 votes
1 answer

Import a module from a relative path?

Assuming that both your directories are real ...READ MORE

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

How do I check if a string contains a specific word?

You can use the strpos() function which is used ...READ MORE

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

How to iterate a Json file which has multiple key value pairs and also nested list as part of the file?

I think you need to create some ...READ MORE

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

List changes unexpectedly after assignment. How do I clone or copy it to prevent this?

With new_list = my_list, you don't actually have ...READ MORE

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

How to check if a string contains a substring in Bash?

string='My long string' if [[ $string == ...READ MORE

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

How to choose the value and label from Django ModelChoiceField queryset?

Hello @kartik, In your Person model add: def __unicode__(self): ...READ MORE

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

when I run this, I get TypeError: int() takes at most 2 arguments (3 given). How to solve this?

Hi@MUHAMMAD, You are trying to pass State in ...READ MORE

Sep 7, 2020 in Python by akhtar
• 38,260 points
4,862 views
0 votes
1 answer

“Least Astonishment” and the Mutable Default Argument

Actually, this is not a design flaw, ...READ MORE

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

Please Help me About this Pygame Error installing on pip

Hi, @Micheal, Download pygame‑1.9.3‑cp37‑cp37m‑win_amd64. While if you have a 64-bit ...READ MORE

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

ModuleNotFoundError: No module named 'line_profiler'.

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

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

What does the “yield” keyword do?

To understand what yield does, you must understand what generators are. ...READ MORE

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

pandas._libs.tslib.OutOfBoundsDatetime: Out of bounds nanosecond timestamp

Hi@akhtar, I think you need to upgrade or reinstall ...READ MORE

Jul 16, 2020 in Python by MD
• 95,460 points
7,067 views
0 votes
1 answer

python code for fall detection of a video file

Hello @Aruna, You can refer this for your ...READ MORE

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

I have created python chatbot using flask framework using yml file now i want to use json file what should i do now ?

Hello @golu , Try something like this: with open(yaml_file, 'r') ...READ MORE

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

How to get an absolute file path in Python?

Hello @kartik, Try this out: >>> import os >>> os.path.abspath("mydir/myfile.txt") 'C:/example/cwd/mydir/myfile.txt' Also ...READ MORE

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

How do I change the working directory in Python?

Hello @kartik, use os.chdir like this: os.chdir("/path/to/change/to") By the way, if you ...READ MORE

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

How to import an image into a csv file using python?

I am sure you are aware CSV ...READ MORE

Jun 25, 2020 in Python by Bhanu Kumar
7,933 views
0 votes
1 answer

How do you split a list into evenly sized chunks?

Here's a generator that yields the chunks ...READ MORE

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

How can I open multiple files using “with open” in Python?

Hello @kartik, Just replace and with , and you're done: try: ...READ MORE

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

How can I open multiple files using “with open” in Python?

Hello, Just replace and with , and you're done: try: ...READ MORE

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

ValueError: too many values to unpack (expected 3)

Hello @Alisha , Do print(func(x)) and find out what's ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,840 points
5,823 views