我有以下网址。
import pandas as pd
import numpy as np
df = pd.DataFrame({
'time' : pd.date_range('2017-07-18 00:00:00', '2017-07-21 00:00:00', freq='3H'),
'val1' : np.random.random(25)*300,
'val2' : np.random.random(25)*30})
real_values = pd.DataFrame({
'day' : [18, 19, 20],
'values' : [500, 600, 700]})
df['day'] = df['time'].apply(lambda x: x.day)
df = df.merge(real_values, how='left', on='day')
df['mean'] = df.groupby('day')['val1'].transform('mean')
df['val1'] = df['val1'] * df['values'] / df['mean']
df.set_index('time', inplace=True)
我想将%20替换为连字符...我该如何更改? 我尝试使用以下行。
http://dubaiexporters.com/searchsubcat.aspx?cat=Automotive&subcat=Auto%20Spare%20Parts
答案 0 :(得分:2)
您必须先用' - '替换'%20'。之后你可以使用HttpUtility.UrlEncode。请查看代码。我在在线模拟器(http://rextester.com/)
上测试了它string url=TextBoxSearch.Text;
url=url.Replace("%20", "-");
Console.WriteLine(url);
var encode = System.Web.HttpUtility.UrlEncode(url);
Console.WriteLine(encode);