Python Forum
changing characters in multiple strings in a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing characters in multiple strings in a list
#3
Below code will work well for whatever in between "-"
#!/usr/bin/python
import glob
from __future__ import print_function

for fileName in glob.glob('CT-*'):
        fileName = fileName.split('-')
        fileName[1] = '008'
        fileName = '-'.join(fileName)
        print(fileName)
Reply


Messages In This Thread
RE: changing characters in multiple strings in a list - by kannanv110 - Feb-23-2018, 03:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read module/class from list of strings? popular_dog 1 541 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 858 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  problem in using int() with a list of strings akbarza 4 818 Jul-19-2023, 06:46 PM
Last Post: deanhystad
  xml indent SubElements (wrapping) with multiple strings ctrldan 2 1,599 Jun-09-2023, 08:42 PM
Last Post: ctrldan
  Delete strings from a list to create a new only number list Dvdscot 8 1,674 May-01-2023, 09:06 PM
Last Post: deanhystad
  Help with Logical error processing List of strings dmc8300 3 1,156 Nov-27-2022, 04:10 PM
Last Post: Larz60+
  Splitting strings in list of strings jesse68 3 1,847 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Search multiple CSV files for a string or strings cubangt 7 8,299 Feb-23-2022, 12:53 AM
Last Post: Pedroski55
  How to combine multiple rows of strings into one using pandas? shantanu97 1 3,212 Aug-22-2021, 05:26 AM
Last Post: klllmmm
  Why changing data in a copied list changes the original list? plumberpy 3 2,290 Aug-14-2021, 02:26 AM
Last Post: plumberpy

Forum Jump:

User Panel Messages

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