Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中如何将PUT请求的字符串与HTML连接起来?_Python_Html_Json_Pandas_Python Requests - Fatal编程技术网

在Python中如何将PUT请求的字符串与HTML连接起来?

在Python中如何将PUT请求的字符串与HTML连接起来?,python,html,json,pandas,python-requests,Python,Html,Json,Pandas,Python Requests,我目前的代码是: import requests import base64 import pandas as pd pat = 'TO BE FILLED BY YOU' #CONFIDENTIAL authorization = str(base64.b64encode(bytes(':'+pat, 'ascii')), 'ascii') headers = { 'Accept': 'application/json', 'Authorization': 'Basic

我目前的代码是:

import requests
import base64
import pandas as pd

pat = 'TO BE FILLED BY YOU'  #CONFIDENTIAL
authorization = str(base64.b64encode(bytes(':'+pat, 'ascii')), 'ascii')

headers = {
    'Accept': 'application/json',
    'Authorization': 'Basic '+authorization
}

df = pd.read_csv('sf_metadata.csv')  #METADATA OF 3 TABLES CURRENCY,SALES,SF_INVENTORIES
df.set_index('TABLE_NAME', inplace=True,drop=True)
df_test1 = df.loc['CURRENCY'] 

x1 = df_test1.to_html()  # CONVERTING TO HTML TO PRESERVE THE TABULAR STRUCTURE

#JSON FOR PUT REQUEST
SamplePage1 = {
  "content": x1
}

#API CALLS TO AZURE DEVOPS WIKI 
response = requests.put(
    url="https://dev.azure.com/xxx/DIFTEST/_apis/wiki/wikis/xxx.wiki/pages?path=SamplePag1&api-version=6.0", headers=headers,json=SamplePage1)
我能够获得以下输出:

我有一个变量:

str1 = "View HIST_DUMPS - Dispatch Dump Record\nDatabase name : PROD_WG\nSchema name : MineOPs"
我需要将str1与x1连接起来,以便我的输出(在执行PUT请求后)如下所示:
有人能帮我吗?我怎样才能做到这一点。谢谢。

您只需使用
+
操作符将
str1
x1
字符串附加在一起,即可进行字符串连接,并更新json dict

我已经更新了
str1
,以便在下面的示例中使用html

str1=“查看历史转储-调度转储记录
数据库名称:PROD\u WG
架构名称:MineOPs

” 标题为str1+x1的表 #用于PUT请求的JSON 样本页1={ “内容”:带有标题的表格 } #对AZURE DEVOPS WIKI的API调用 response=requests.put( url=”https://dev.azure.com/xxx/DIFTEST/_apis/wiki/wikis/xxx.wiki/pages?path=SamplePag1&api-version=6.0”,headers=headers,json=SamplePage1)
产生如下输出(snip中不可见的表格):