Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Number of characters
#1
Hello, im begginer in python. I have a problem with cycle.

i have text.txt
Quote:Text
The text denotes any combination of words that together make a statement.
Mostly, however, the text is denoted by some separate or paragraph.
The word text is used for written statements.
Books are labeled as artistic texts, newspaper articles as publicity texts,

work.py

import os 
import sys

cesta_vstup_rel = 'text.txt' 

cesta_vystup_rel = 'text_vystup.txt'

if not os.path.exists(cesta_vstup_rel): 
    print 'vstupni soubor nenalezen!'
    sys.exit() 

vstup = open(cesta_vstup_rel, 'r') 
radky = vstup.readlines() 
vstup.close() 

zapis = open(cesta_vystup_rel, 'w') #oteviram soubor pro zapis (w-write)

for radek in radky:
    zapis.write(radek.strip('\n') + '[b]number of characters[/b]')

zapis.close()
i need make numbers of all characters on end of line, like this:
Quote:Text4
The text denotes any combination of words that together make a statement.73
Mostly, however, the text is denoted by some separate or paragraph.67
The word text is used for written statements.45
Books are labeled as artistic texts, newspaper articles as publicity texts,75

Please help me, i working on it all night... :) Thank you
Reply


Messages In This Thread
Number of characters - by ejstik - Jan-10-2018, 03:51 AM
RE: Number of characters - by Larz60+ - Jan-10-2018, 04:50 AM
RE: Number of characters - by ejstik - Jan-10-2018, 10:40 AM
RE: Number of characters - by Larz60+ - Jan-10-2018, 11:45 AM
RE: Number of characters - by ejstik - Jan-11-2018, 02:25 AM
RE: Number of characters - by Larz60+ - Jan-11-2018, 02:28 AM
RE: Number of characters - by ejstik - Jan-11-2018, 02:58 AM
RE: Number of characters - by Larz60+ - Jan-11-2018, 04:30 AM
RE: Number of characters - by ejstik - Jan-11-2018, 07:57 AM
RE: Number of characters - by Larz60+ - Jan-11-2018, 12:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find if chain of characters or number Frankduc 4 1,752 Feb-11-2022, 01:55 PM
Last Post: Frankduc
  Remove escape characters / Unicode characters from string DreamingInsanity 5 13,429 May-15-2020, 01:37 PM
Last Post: snippsat
  Split Column Text by Number of Characters cgoldstein 3 2,949 Mar-11-2019, 01:45 PM
Last Post: perfringo
  Counting number of characters in a string Drone4four 1 3,411 Aug-16-2018, 02:33 PM
Last Post: ichabod801
  How can i restrict the number of characters in an input? kevencript 1 3,985 May-23-2018, 05:14 AM
Last Post: micseydel
  Regex: How to say 'any number of characters of any type until x'? JoeB 2 2,351 Jan-24-2018, 03:30 PM
Last Post: Mekire
  The number of occurrences of statistical characters RobertW 3 5,206 Jan-18-2018, 10:10 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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