string objects...

G

google account

I know that string.letters and string.digits are all the letters and
numbers, is there a string.???? that is a subset of all the ascii
characters that are available on a US English Keyboard without going
to special characters (like ß or ¿)

I couldnt see anything that was explaining this stuff on the
python.org site.

I think what I want is soemthing like string.printable -
string.whitespace but that doesn't seem to work like string.letters +
string.numbers...


TIA


Googleboy
 
L

Lukasz Pankowski

I know that string.letters and string.digits are all the letters and
numbers, is there a string.???? that is a subset of all the ascii
characters that are available on a US English Keyboard without going
to special characters (like ß or ¿)

I couldnt see anything that was explaining this stuff on the
python.org site.

I think what I want is soemthing like string.printable -
string.whitespace but that doesn't seem to work like string.letters +
string.numbers...

Minus does not work on string, as there is now obvious meaning of
this: cut from the end, or a set like minus you would be happy this
time

You may use list comprehension to filter out all whitespace from
printable and than join the list with empty separator:
import string
''.join([c for c in string.printable if c not in string.whitespace])
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top