February 4th, 2013, 09:45 AM
-
String and regexp
Hi
I am very new to python and have a simple task -
Given a string "0x8bb860" I need to determine if if starts with the characters "0x"
I have tried
x = "0x8bb860
print x.startswith("0x")
but this gives me an exception
How is the correct way to do this?
Thanks
February 4th, 2013, 10:13 AM
-
Originally Posted by grahamlabdon
How is the correct way to do this?
Add the ending double quote and, if you are using Python 3, use parentheses:
Code:
x = "0x8bb860"
print(x.startswith("0x"))
My armada: Debian GNU/Linux 8 (desktop, home laptop, work laptop), Raspbian GNU/Linux 8 (nameserver), Ubuntu 14.04.3 LTS (HTPC), PC-BSD 10.2 (testbed), Android 4.2.1 (tablet)
February 4th, 2013, 10:14 AM
-