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 25197 bartonc 6,596
Recognized Expert Expert
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 problems getting my
algorithm to work and in order to help me find the solution I decided to
print each line to screen as I read them.
Then, to my...
|
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 for storing the XML value. This makes
my life a bit easier since I can easilly reallocate space to include
the required new 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.
txtS_Filename.Text.Replace("C:\", "");
The compiler has a problem with the newline slash character but even
|
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 "server1" part (which could be
| |
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.
However, I would like to replace the id and first_name in table1 to: 3 and 'nil' to insert into table2.
INSERT INTO table2 SELECT * FROM...
|
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 special characters like < ,/ with encoded like '#231'
my real problem is wich replace function to use to do it in the whole string?? i know how to...
|
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
www.websiteurl.com/PageName.aspx/Attribute1/Attribute2
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |