Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91587

Are there any other better ways to access a single bit of string of digits?

Newsgroups comp.lang.python
Date 2015-05-31 11:36 -0700
Message-ID <68680e6e-b914-4bef-b16b-1fa48b00eaf2@googlegroups.com> (permalink)
Subject Are there any other better ways to access a single bit of string of digits?
From fl <rxjwg98@gmail.com>

Show all headers | View raw


Hi,

I am new to Python. I would manipulate a string of hex numbers. If the first
digit is bigger than 7, the first two digits are required to add 4.

For example, '8022_3345' will be changed to '8422_3345'. The 
underscore between two 4-digit's was generated previously (i.e.
it is already in the .txt file).

I have not tried to read the .txt file to a list yet. I just try the
following:

tmp
['12345678', '23456789', '3456789a', '456789ab']

Each 8-digit hex number is assigned to a variable, such as:

digit8=tmp[0]

 
I can compare digit8[0] with 7, and so on...



The underscore, I think, can be removed by first a string replace.

My question here is:

Do you have better ways than my tmp, digit8 operation?


Thanks,

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Are there any other better ways to access a single bit of string of digits? fl <rxjwg98@gmail.com> - 2015-05-31 11:36 -0700
  Re: Are there any other better ways to access a single bit of string of digits? Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-31 19:51 +0000
    Re: Are there any other better ways to access a single bit of string of digits? fl <rxjwg98@gmail.com> - 2015-05-31 13:08 -0700

csiph-web