python – 与input()和raw_input()相关的安全问题的简单解释
发布时间:2020-12-20 11:43:59 所属栏目:Python 来源:网络整理
导读:参见英文答案 Is it ever useful to use Python’s input over raw_input?????????????????????????????????????4个 我正在阅读这篇Python 2.7教程,他们将讨论raw_input(),并提到: The input() function will try to convert things you enter as if they w
参见英文答案 >
Is it ever useful to use Python’s input over raw_input?????????????????????????????????????4个
我正在阅读这篇Python 2.7教程,他们将讨论raw_input(),并提到:
我尝试用谷歌搜索一些解释,但对我来说仍然有点不清楚;什么是对input()vs raw_input()所谓的固有安全问题的简单解释? 解决方法
Python 2.x中的input()函数在返回之前评估事物.
举个例子,你可以看看这个 – >>> input("Enter Something : ") Enter Something : exit() 这将导致程序退出(因为它将评估exit()). 另一个例子 – >>> input("Enter something else :") Enter something else :__import__("os").listdir('.') ['.gtkrc-1.2-gnome2',...] 这将列出当前目录的内容,你也可以使用os.chdir(),os.remove(),os.removedirs(),os.rmdir()等函数. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |