如何从用户输入标题

时间:2016-01-11 05:03:57

标签: python pycurl

我想添加值以接收用户对标题的输入。

但是,在声明变量头时,由于两个变量(x_user,x_key)而发生错误。

1。存储在file.csv中的用户数据

输入命令是

ID = input("input the customer email id: ")
cList(ID)


def cList(value):
    with open(DIR, newline='') as f:
        data = csv.reader(open(DIR, "r"))
        for row in data:
            MEM_ID = row[0]
            MEM_SQ = row[1]
            X_AUTH_USER = row[2]
            X_AUTH_KEY = row[3]
            X_STORAGE_URL = row[4]
            ACCESSKEY = row[5]

2。它将变量分配给函数。

aList( X_AUTH_USER, X_AUTH_KEY)`

第3。 aList的功能使用了pycurl模块。

def aList(x_user, x_key):
        headers = ['X-Storage-User:'x_user, 'X-Storage-Pass:'x_key]
        pycurl_connect = pycurl.Curl()
        pycurl_connect.setop(pycurl.CAINFO, certifi.where())
        pycurl_connect.setopt(pycurl.URL, STORAGE_URL)
        pycurl_connect.setopt(pycurl.HTTPHEADER, headers)
        pycurl_connect.setopt(pycurl.WRITEFUNCTION, bodycb)
        pycurl_connect.setopt(pycurl.HEADERFUNCTION, headercb)
        pycurl_connect.perform()

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。 (未使用pycurl)

请求模块是一个非常好的库。

def gList(auth_url,auth_token):
container = input("inpurt container: ")
headers = {'X-Auth-Token':auth_token}
req = requests.get(auth_url+container, headers=headers)
print(req.headers)