我正在尝试将两个目录传递给我的python脚本,该脚本只打印出目录。但不知何故它不起作用。以下是代码
shellscript.sh:
set VAR1=$(pwd)
echo $VAR1
set VAR2=$(pwd)
echo VAR2
python.exe mypython_script.py "$VAR1" "$VAR2"
mypython_script.py:
import os
import sys
if __name__ = '__main__':
print(sys.argv[1])
print(sys.argv[2])
echo
正在打印路径,但终端也会打印脚本调用行。它显示python.exe mypython_script.py '' ''
然后打印语句正在打印空字符串。任何人都可以向我指出问题所在吗?谢谢
答案 0 :(得分:3)
你的问题在于
extension Dictionary {
public func deepMerged(with other: [Key: Value]) -> [Key: Value]
{
var result: [Key: Value] = self
for (key, value) in other {
if let value = value as? [Key: Value],
let existing = result[key] as? [Key: Value],
let merged = existing.deepMerged(with: value) as? Value
{
result[key] = merged
} else {
result[key] = value
}
}
return result
}
}
你应该使用
set VAR1=$(pwd)
代替。