开发者

How can I convert string to "command" in Python?

开发者 https://www.devze.com 2022-12-21 18:15 出处:网络
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>

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

精彩评论

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

关注公众号