How can I convert string to "command" in Python?
How can I convert this so it could execute?
Traceback (most recent call last):
File "C开发者_如何学Python:\Users\Shady\Desktop\tet.py", line 14, in <module>
exec test
File "<string>", line 1
print "hello world"
^
IndentationError: unexpected indent
source:
test = ''.join(clientIp.split("test6")[1:])
You might need to use lstrip()
on the string to get rid of any leading whitespace before passing it to exec
.
精彩评论