[英]Concatenation the string values in python
I am trying to concatenation the string values like below in the python我正在尝试在 python 中连接如下所示的字符串值
args = parser.parse_args() args = parser.parse_args()
regionCode = args.regionCode区域代码 = args.regionCode
azure_api_token = args.azure_api_token azure_api_token = args.azure_api_token
computerName = args.computerName计算机名 = args.计算机名
targetOu = 'OU=XXX,OU=$regionCode,OU=XXX,DC=XXX,DC=XX' targetOu = 'OU=XXX,OU=$regionCode,OU=XXX,DC=XXX,DC=XX'
in the regioncode I am fetching the value from the build parameters I am trying to assign it in the target OU $regioncode but the value is not fetching or substituting在区域代码中,我正在从构建参数中获取值我试图在目标 OU $regioncode 中分配它,但该值未获取或替换
can someone please help me with the command how to substitute the variable value into the target OU有人可以帮我用命令如何将变量值替换为目标 OU
To substitute a variable in a string in python you can do in many different ways.要替换 python 中字符串中的变量,您可以采用多种不同的方式。
Here you can do:在这里你可以做:
python 2: python 2:
targetOu = 'OU=XXX,OU={},OU=XXX,DC=XXX,DC=XX'.format(regionCode)
python 3: python 3:
targetOu = f'OU=XXX,OU={regionCode},OU=XXX,DC=XXX,DC=XX'
There are many other ways to do so.还有许多其他方法可以做到这一点。 But this has been answered in so many different threads that I won't bother writing other solutions.但这已经在许多不同的线程中得到了回答,我不会费心编写其他解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.