开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜