Jan-22-2018, 11:27 PM
Hello everyone!
I've been trying my hand at a simple curses GUI for a short program. I wanted the program to be able to respond to key presses without the user having to press return, but there were also times when I wanted to have the user type a line of text and hit return, as normally happens with a text console
After trying to wade through a couple basic tutorials and the python documentation, I realized that the following line seemed to work as expected...
b'myString'
I kind of have a intuitive guess that the string is in 'bytecode' but I don't know how reformat this strange string format into something i can use in my program
curses has no problem, and...
myString
but the normal python print() statement
b'myString'
and if i try
b'myString'
and finally, trying
b'yStrn'
So maybe this is a python question as much as a curses question:
But how can I convert this string into a "normal everyday python string"?
Thanks in advance!!
I've been trying my hand at a simple curses GUI for a short program. I wanted the program to be able to respond to key presses without the user having to press return, but there were also times when I wanted to have the user type a line of text and hit return, as normally happens with a text console
After trying to wade through a couple basic tutorials and the python documentation, I realized that the following line seemed to work as expected...
st = window.getstr( y, x )...except that the string was formatted as
b'myString'
I kind of have a intuitive guess that the string is in 'bytecode' but I don't know how reformat this strange string format into something i can use in my program
curses has no problem, and...
window.addstr( y, x, st )...prints out the string normally:
myString
but the normal python print() statement
print( st )produces the output:
b'myString'
and if i try
print( str( st ) )didn't help and the output was:
b'myString'
and finally, trying
print( st[2:-1] )it did not have the result expected:
b'yStrn'
So maybe this is a python question as much as a curses question:
But how can I convert this string into a "normal everyday python string"?
Thanks in advance!!
