473,473 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

strings

Hi All!

I have a
'Pink Floyd/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00'
and I want a
'Pink Floyd'
How can I manage it?

This one isn't work.
author=f.read(30).replace('\0',' ').rstrip() #from mp3 tag
--
Egor [ru eo en]
Jul 18 '05 #1
2 1933
On Mon, 30 Jun 2003 09:54:24 +1100, "Egor Bolonev" <eb******@mail.ru> wrote:
Hi All!

I have a
'Pink Floyd/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00'
and I want a
'Pink Floyd'
How can I manage it?

This one isn't work.
author=f.read(30).replace('\0',' ').rstrip() #from mp3 tag

Trick question ;-)
pf = 'Pink Floyd/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00'
pf[:pf.index('/x00')] 'Pink Floyd' list(pf)

['P', 'i', 'n', 'k', ' ', 'F', 'l', 'o', 'y', 'd', '/', 'x', '0', '0', '/', 'x', '0', '0', '/',
'x', '0', '0', '/', 'x', '0', '0', '/', 'x', '0', '0', '/', 'x', '0', '0', '/', 'x', '0', '0', '
/', 'x', '0', '0', '/', 'x', '0', '0', '/', 'x', '0', '0', '/', 'x', '0', '0', '/', 'x', '0', '0
']

I.e., '/x00' is not '\x00' ;-)

Regards,
Bengt Richter
Jul 18 '05 #2
On Mon, 30 Jun 2003 10:27:52 +1100, "Egor Bolonev" <eb******@mail.ru> wrote:
> Hi All!
>
> I have a
> 'Pink Floyd/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00/x00'
> and I want a
> 'Pink Floyd'
> How can I manage it?
>
> This one isn't work.
> author=f.read(30).replace('\0',' ').rstrip() #from mp3 tag If you are playing around with various methods, don't forget
to f.seek(0) between (assuming what you have is at the beginning of the file).
>


That is weird. Are you sure? It works on my system:
(BTW: I think you mean \x00 instead of /x00)
>>> a='Pink Floyd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00'
>>> a

'Pink Floyd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00'
>>> a.replace('\0',' ').rstrip()

'Pink Floyd'
>>>


Yes it's weird. The Interactive window of PythonWin shows it correct, but
debugger window is not.:-(

Did you try it with a fixed string like a above?

BTW, a.replace('\0','') should work without creating and then stripping spaces, I think.
also a.rstrip('\0') -- though the meanings of all these are different if \x00 occurs internally,
not just in the tail.

Regards,
Bengt Richter
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT"...
17
by: Gordon Airport | last post by:
Has anyone suggested introducing a mutable string type (yes, of course) and distinguishing them from standard strings by the quote type - single or double? As far as I know ' and " are currently...
16
by: Paul Prescod | last post by:
I skimmed the tutorial and something alarmed me. "Strings are a powerful data type in Prothon. Unlike many languages, they can be of unlimited size (constrained only by memory size) and can hold...
4
by: agent349 | last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1 == array2)). However, I've been trying to compare two arrays using pointers with no success. Basically, I want to take three...
25
by: Rainmaker | last post by:
Hi, Can anyone tell me an efficient algorithm to sort an array of strings? Keep in mind that this array is HUGE and so the algorithm should me efficient enough to deal with it. Thanks
6
by: Broeisi | last post by:
Hello, I wrote the tiny progam below just to understand arrays and strings better. I have 2 questions about arrays and strings in C. 1. Why is it that when you want to assign a string to an...
2
by: Potiuper | last post by:
Question: Is it possible to use a char pointer array ( char *<name> ) to read an array of strings from a file in C? Given: code is written in ANSI C; I know the exact nature of the strings to be...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
95
by: hstagni | last post by:
Where can I find a library to created text-based windows applications? Im looking for a library that can make windows and buttons inside console.. Many old apps were make like this, i guess ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
0
agi2029
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.