questions/python/page/20
Strings: >>> n = '4' >>> print(n.zfill(3)) 004 And for numbers: >>> ...READ MORE
One thing you can try is to ...READ MORE
It's safer to use a try around the attempt ...READ MORE
Use __import__ function to import the module by giving ...READ MORE
You need to double the {{ and }}: >>> x = ...READ MORE
Hello, You need to use os.path.expanduser. This will ensure it works ...READ MORE
A TypeError can occur if the type ...READ MORE
No need to put filename.txt For directory check path ...READ MORE
Hey, @Sushruth, Here the code goes for Motion Detector.py import ...READ MORE
Hi, @Varshap It’s a TypeError, which tells us ...READ MORE
Example class Date(object): def __init__(self, ...READ MORE
Have you tried the __name__ attribute of the class? ie type(x).__name__ will ...READ MORE
from nsepy import get_history from datetime import date import ...READ MORE
d = {'key': 'value'} print(d) # {'key': 'value'} d['mynewkey'] = ...READ MORE
Hello, For your query you can refer this:https://www.programmersought.com/article/5321489391/ Hope ...READ MORE
Hello @kartik, Try this out: import socket s = socket.socket(socket.AF_INET, ...READ MORE
Assuming that both your directories are real ...READ MORE
Hello @kartik, In your Person model add: def __unicode__(self): ...READ MORE
You can use the strpos() function which is used ...READ MORE
os.remove() removes a file. os.rmdir() removes an empty directory. shutil.rmtree() deletes a ...READ MORE
With new_list = my_list, you don't actually have ...READ MORE
I think you need to create some ...READ MORE
Hello @Alisha , Do print(func(x)) and find out what's ...READ MORE
Hi@MUHAMMAD, You are trying to pass State in ...READ MORE
Hi@akhtar, You need to install the module in ...READ MORE
Hi, @Micheal, Download pygame‑1.9.3‑cp37‑cp37m‑win_amd64. While if you have a 64-bit ...READ MORE
string='My long string' if [[ $string == ...READ MORE
I am sure you are aware CSV ...READ MORE
As mentioned in the error logs, try ...READ MORE
Hello @kartik, You can use dict.get() value = d.get(key) which will ...READ MORE
Hi@akhtar, I think you need to upgrade or reinstall ...READ MORE
Actually, this is not a design flaw, ...READ MORE
Hello @golu , Try something like this: with open(yaml_file, 'r') ...READ MORE
Hello @Aruna, You can refer this for your ...READ MORE
To understand what yield does, you must understand what generators are. ...READ MORE
Python supports all the concept of "object ...READ MORE
Just import file without the '.py' extension. You can mark ...READ MORE
Hello @kartik, Just replace and with , and you're done: try: ...READ MORE
Here's a generator that yields the chunks ...READ MORE
Hello @kartik, use os.chdir like this: os.chdir("/path/to/change/to") By the way, if you ...READ MORE
Hello @kartik, Try this out: >>> import os >>> os.path.abspath("mydir/myfile.txt") 'C:/example/cwd/mydir/myfile.txt' Also ...READ MORE
Hi, @Rhydham, Try this: engine = pyttsx3.init('dummy') If you want ...READ MORE
You need to implement your own __repr__ ...READ MORE
Hello, Just replace and with , and you're done: try: ...READ MORE
Hey, @Natraj, This basically means that no response ...READ MORE
Hi, @There, $ pip install gevent --pre $ pip ...READ MORE
I have the same issue and is ...READ MORE
Appends object at the end. x = [1, ...READ MORE
It's because any iterable can be joined ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.