Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: How can I change a string.
Post: RE: How can I change a string.

(Jun-03-2020, 10:13 AM)buran Wrote: var = 'When parents goWhat do they listen toWhy' words = ['When', 'Why', 'What', 'How'] for word in words: if not var.startswith(word): var = var.repl...
Mike Ru General Coding Help 3 2,448 Jun-03-2020, 10:39 AM
    Thread: How can I change a string.
Post: How can I change a string.

I have a string. I need to find words and change them if it there are over there. I am trying something like this. But I doesn't work. I need to get new string something like this. When parents go. W...
Mike Ru General Coding Help 3 2,448 Jun-03-2020, 10:03 AM
    Thread: Sutil.copytree, I'm getting File Exists.
Post: Sutil.copytree, I'm getting File Exists.

I have a folder 'target' with other folders that have folders called 'env'. I am trying to copy all files/directories from 'target' to 'backup_folder' without 'env'. #!/usr/bin/env python3.8 import g...
Mike Ru General Coding Help 1 8,637 Oct-27-2019, 11:58 PM
    Thread: How can I sort my names of files in for loop?
Post: How can I sort my names of files in for loop?

I have some files. I am running my script. import os list_files = os.listdir('.') for x in list_files: print(x)output: [DownSub.com] Beginner Levels - Lesson 13 - Practical English Drama.srt [D...
Mike Ru General Coding Help 2 2,538 Aug-01-2019, 11:26 PM
    Thread: Why am I getting KeyError 'file' when using argparse?
Post: Why am I getting KeyError 'file' when using argpar...

I'm trying to do that, but getting KeyError 'file' import argparse parser.add_argument('-s', '--server', '-f', '--file', metavar='', required=False, help="name of the user") print(args['server'], arg...
Mike Ru General Coding Help 1 3,077 Jun-09-2019, 04:02 PM
    Thread: How can I get some arguments using argparse?
Post: How can I get some arguments using argparse?

I am using a module argparse. I need to get arguments and then do something. I can only one argument now, but I cannot get some arguments if an user types two arguments. python demo.py -c work.txtNow...
Mike Ru General Coding Help 0 1,879 Jun-05-2019, 12:57 PM
    Thread: How can I change value of dict in list?
Post: How can I change value of dict in list?

I have it phone_books = [ {'id': 0, 'name': 'Mike', 'number': 1111111}, {'id': 1, 'name': 'Sasha', 'number': 2222}, ]I resolved it like that: for x in phone_books: if x.get('id', 0) == 1: ...
Mike Ru General Coding Help 1 1,925 May-13-2019, 08:59 PM
    Thread: How can I sort my dict ?
Post: How can I sort my dict ?

I have it {1: ['3', ['third task', True]], 2: ['1', ['first task', True]], 3: ['2', ['second task', True]]}I need to get sort dict like that {1: ['1', ['first task', True]], 2: ['2', ['second task', ...
Mike Ru General Coding Help 1 1,811 Feb-16-2019, 11:43 PM
    Thread: Why am I getting this error?
Post: RE: Why am I getting this error?

I resoleved it. I should move conn.close() into except except IndexError: conn.close() print('done')
Mike Ru Web Scraping & Web Development 1 2,891 Nov-22-2018, 03:06 PM
    Thread: Why am I getting this error?
Post: Why am I getting this error?

I'm trying to add some data from a file, but getting this error. Traceback (most recent call last): File "spider.py", line 142, in <module> main() File "spider.py", line 140, in main ...
Mike Ru Web Scraping & Web Development 1 2,891 Nov-22-2018, 12:12 PM
    Thread: How can I add some data from file.txt to db.sqlite3 ?
Post: RE: How can I add some data from file.txt to db.sq...

I have just resolved it like that def add(): db = sqlite3.connect('../project/db.sqlite3') cursor = db.cursor() f = open('subject.txt') line = f.readline() while line: ...
Mike Ru General Coding Help 1 3,075 Nov-19-2018, 05:35 AM
    Thread: How can I add some data from file.txt to db.sqlite3 ?
Post: How can I add some data from file.txt to db.sqlite...

I have a subject.txt with content like this Accidents at Home Adoption Advertising Advice Age: Youth & Old Age Airplanes Amusement Parks I have a table of 'subject' in db.sqlite3 sqlite> .sche...
Mike Ru General Coding Help 1 3,075 Nov-19-2018, 04:10 AM
    Thread: How can get first 255 bites from a string?
Post: How can get first 255 bites from a string?

I have a string that too long. I need to cut it to 255 bites. I don't know how to cut it. import sys def get_bite(a): return sys.getsizeof(a) def main(): mystring = '3 - Научиться спрашивать ...
Mike Ru General Coding Help 2 2,452 Oct-22-2018, 06:57 PM
    Thread: How can I return my list from a func?
Post: How can I return my list from a func?

I have a list. I'm getting items that starting from number. s = ['kdkkd', '1 america', 'wwww', '2 Russia', 'd333', '3England'] def get_title_list(a): for x in mylist: try: int(...
Mike Ru General Coding Help 3 3,094 Oct-22-2018, 11:53 AM
    Thread: How dont' show hidden system files
Post: RE: How dont' show hidden system files

(Jan-11-2018, 12:55 PM)Larz60+ Wrote: import os   def get_dir(dir):     return [file for file in os.listdir(dir) if not file.startswith('.')]   print(get_dir('Z:/python/forum/inspect/')) It shows al...
Mike Ru General Coding Help 5 9,604 Jan-11-2018, 01:14 PM
    Thread: How dont' show hidden system files
Post: RE: How dont' show hide system files

(Jan-11-2018, 12:44 PM)Larz60+ Wrote: Go after the files you are interested in import glob def get_dir(dir): for file in glob.glob(dir): print(file) get_dir('Z:/python/forum/inspect/*...
Mike Ru General Coding Help 5 9,604 Jan-11-2018, 12:47 PM
    Thread: How dont' show hidden system files
Post: How dont' show hidden system files

I'm using Windows now. I would like know how I can don't show hidden files in Windows. For example: import os print(os.listdir(r'C:/Users/mike/'))But I need to get only my files. How can I hide AppDat...
Mike Ru General Coding Help 5 9,604 Jan-11-2018, 12:30 PM
    Thread: BeautifulSoup and pagination.
Post: BeautifulSoup and pagination.

I have a script that download MP3  on the site. I don't know how to pass other page to download other music after downloading of all music on the page. It seem to me that I should add some nambers to ...
Mike Ru Web Scraping & Web Development 1 7,902 Sep-22-2017, 08:43 AM
    Thread: Why my status is silly Frenchman?
Post: Why my status is silly Frenchman?

If to translate it (silly Frenchman) to Russian language it will be Глупый Француз. But I'm not Frenchman and I'm not silly ! )
Mike Ru Bar 4 3,423 Aug-05-2017, 06:18 PM
    Thread: How can I check out my localhost?
Post: RE: How can I check out my localhost?

(Aug-05-2017, 05:21 AM)buran Wrote: because your localhost is not working. i.e. you don't get any response (and its status code), but  errorsSuper. Thank you so much!
Mike Ru Homework 2 3,608 Aug-05-2017, 05:50 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020