当前位置:首页 > Python教程 > python技巧

python post提交

             1
            #
             coding:utf8
             2
            import
             requests

             3
            def
             login():

             4     url = http://back.xiyilang.cc/staff/login.json 5     headers={X-Forwarded-For:127.0.0.1} #ip转化 6     data={
 7staffCode:00025, #用户 8password:123456,#密码 9    }
10     x = requests.post(url,data,headers=headers) #登陆账号密码11     cookie = x.cookies  #cookie=cookies 获取cookie等待下次调用12return cookie
13 cookie = login()
14def lvaue(id):
15     url = http://back.xiyilang.cc/admin/staff-admin!search.json16     headers = {X-Forwarded-For: 127.0.0.1}
17     data = {
18staffId:id,
19    }
20     x = requests.post(url,data,headers=headers,cookies=cookie).text #再次进行调用cookie21print x
22 y=raw_input(id:)
23 lvaue(y)

*

input()  #危险  __import__(‘os‘).system(‘dir‘) 可执行

raw_imput()

input() 本质上还是使用 raw_input() 来实现的,只是调用完 raw_input() 之后再调用 eval() 函数,所以,你甚至可以将表达式作为 input() 的参数,并且它会计算表达式的值并返回它。

不过在 Built-in Functions 里有一句话是这样写的:Consider using the raw_input() function for general input from users.

除非对 input() 有特别需要,否则一般情况下我们都是推荐使用 raw_input() 来与用户交互

 

原文:http://www.cnblogs.com/Archie-s/p/6843312.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!