【问题标题】:How to input the header from user如何输入用户的标题
【发布时间】:2016-01-11 05:03:56
【问题描述】:

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

但是,声明一个变量头时,由于两个变量(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()

【问题讨论】:

    标签: python pycurl


    【解决方案1】:

    我解决了这个问题。 (没用过pycurl)

    requests 模块是一个非常好的库。

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-18
      相关资源
      最近更新 更多