我实际上是在做一个脚本来后处理一些数据库。你知道吗
我希望我的脚本得到路径和文件名,当我输入一些细节(版本,选项等),它看起来像这样。。。你知道吗
def file_info(version, something, option):
####### This part is the DB
## Version-path
PATH_ver1 = '/ver1'
PATH_something1 = '/something1'
## Name of files, there are bunch of these datas
DEF_ver2_something2 = '/name of file'
DEF_ver2_something1_option4 = '/name of file'
####### Now starts to postprocess
## path setting - other variables also follows this
if version == 'ver1':
PATH_VER = PATH_ver1
elif version == 'ver2':
PATH_VER = PATH_ver2
## Concatenating the paths
PATH_BIN = PATH_TOP + PATH_VER + PATH_TYP + PATH_OPT
## Setting the file name
BIN_file = 'DEF_' + version + '_' + something + '_' + option
return PATH_BIN, BIN_FILE
def main():
version = input("version here")
something = input("something here")
option = input("option here")
output = file_info(version, something, option)
当我输入一些东西时,我可以正确地得到文件的路径,但是文件名给出了变量的名称,而不是'/name of file'。你知道吗
另外,因为我的变量有两个值,我的意思是,它不是一个一个匹配,我想我不能使用字典格式。每个项都有一个键(DEF \***),并且有两个对应的值(PATH \BIN和BIN \FILE)。我怎样才能解决这个问题?你知道吗
听起来您需要的是嵌套字典:
输出:
相关问题 更多 >
编程相关推荐