hi!
i want to replace these characters: - sex_m-designer_bw-size_42
so that i have the argument string: - sex=m&designer=bw&size=42
i am working under zope 3.
glad for any help you can give me (i am veryyyy new in python, so please speak slow).
thank you,
steven, vienna
2 25192
hi!
i want to replace these characters: - sex_m-designer_bw-size_42
so that i have the argument string: - sex=m&designer=bw&size=42
i am working under zope 3.
glad for any help you can give me (i am veryyyy new in python, so please speak slow).
thank you,
steven, vienna
Here, again, the replace() method of a string object will do the job nicely: -
>>> s = "sex_m-designer_bw-size_42"
-
>>> s = s.replace('_', '=')
-
>>> s = s.replace('-', '&')
-
>>> s
-
'sex=m&designer=bw&size=42'
-
>>>
Here, I have used Python's interactive interpreter (denoted by the '>>>' prompt) to run off a quick test of the idea. In interactive mode, all of the built-in types (most of which are true objects in the OOP sense of the term) and functions are available.
Hope I spoke slowly enough,
Barton
Barton,
you are the man!
you saved my day!
(and kept the doctor away)
hurray.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Eric Lilja |
last post by:
Hello, I had what I thought was normal text-file and I needed to locate a
string matching a certain pattern in that file and, if found, replace that
string. I thought this would be simple but I had...
|
by: Locusta |
last post by:
Hello,
I have been struggeling for replacing a string in a string. The snippet
from the program below replaces the <, & and > with the XML equivalent
values.
In the program, I allocate space...
|
by: JPSutor |
last post by:
I want to be able to have a user type in a password to a text box and
1.) Capture the characters entered
2.) Replace typed chars with "*"
|
by: jpierson |
last post by:
Hi,
I'm having a few problems with the replace function for replacing
characters in a textbox.
"C:\" is the string i am tryin to remove ,with it a command I am
sending does not work.
...
|
by: jarod1701 |
last post by:
Hi,
i'm currently trying to replace an unknown string using regular
expressions.
For example I have:
user_pref("network.proxy.http", "server1")
What do I have to do to replace the...
|
by: Umesh |
last post by:
Do you have any answer to it? thx.
|
by: stephcsh |
last post by:
Hi, I wanted to copy a data from table1 in db1 to table2 in db2, which has the same structure, with the PosgreSQL dblink funtion.
The fields for both the tables are: id, first_name, last_name.
...
|
by: chriskaza81 |
last post by:
hello i am very new in xsl ,xml so ....forgive me if i make spuped questions..
well i have the string e.g. <script> blabla bla </script> i want to replace in xsl the ...
|
by: vimalvisves |
last post by:
Hi Friends,
Any one know how to replace query string by slash delimeters, for example i want to replace query string
www.websiteurl.com/PageName.aspx?Param1=Attribute1&Param2=Attribute2
as...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |