eEcho blog

is een halte van de gedachte

Python tekst verwerking

Er zijn functies om tekst te verwerken.
string.atof(s) # Convert to float
string.atoi(s) # Convert to integer
string.atol(s) # Convert to long
string.count(s,pattern) # Count occurrences of pattern in s
string.find(s,pattern) # Find pattern in s
string.split(s, sep) # String a string
string.join(strlist, sep) # Join a list of string
string.replace(s,old,new) # Replace occurrences of old with new

s = "Hello World"
a = string.split(s) # a = [’Hello’,’World’]
b = string.replace(s,"Hello","Goodbye")
c = string.join(["foo","bar"],":") # c = "foo:bar"

Add A Comment

You must be logged in to post a comment.

Home | info@eecho.info | Voorwaarden | Blog