Thanks a lot for this! isDigit was the method I was looking for and couldn’t
find.
I have another problem related to this, the following code uses the code you
just sent. I am getting a files ID3 tags using eyed3, this part seems to work
and I get expected values in this case myTitleName (Track name) is set to
“Deadlock Holiday” and myCompareFileName is set to “01 Deadlock Holiday” (File
Name with the Track number prepended). The is digit test works and
myCompareFileName is set to “Deadlock Holiday”, so they should match, right?
However the if myCompareFileName != myTitleName always gives a mismatch! What
could cause two string that look the fail to not match properly?
myCompareFileName = myFile
if myCompareFileName[0].isdigit() and myCompareFileName[1].isdigit():
myCompareFileName = myCompareFileName[3:]
if myCompareFileName != myTitleName:
print('File Name Mismatch - Artist: ',myArtistName,' Album:
',myAlbumName,' Track:',myTitleName,' File: ',myFile)
Thanks a lot
Dave
> On 7 Jun 2022, at 21:58, De ongekruisigde
> <[email protected]> wrote:
>
> On 2022-06-07, Dave <[email protected]> wrote:
>> Hi,
>>
>> I’m new to Python and have a simple problem that I can’t seem to find the
>> answer.
>>
>> I want to test the first two characters of a string to check if the are
>> numeric (00 to 99) and if so remove the fist three chars from the string.
>>
>> Example: if “05 Trinket” I want “Trinket”, but “Trinket” I still want
>> “Trinket”. I can’t for the life of work out how to do it in Python?
>
>
> s[3:] if s[0:2].isdigit() else s
>
>
>> All the Best
>> Dave
>>
>
> --
> <StevenK> You're rewriting parts of Quake in *Python*?
> <knghtbrd> MUAHAHAHA
> --
> https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list