问题描述 投票:3回答:2

在cmd中运行时,以下python脚本出现错误,当我在cmd中单独运行该命令时,它运行得很好。我不确定是什么引起了这个问题。

错误是:< was unexpected at this time

command = "confluence --action storePage --space 'EN' --title 'csoap-235' --parent '@home' --special ' # ~' --content '<p><ac:link><ri:page ri:content-title=~Home~/></ac:link></p>' --noConvert --server 'server' --user 'username' --password 'pswd'" 
os.system(command)
print "This happened"

任何帮助将不胜感激!

python command-line windows-7 cmd confluence
2个回答
1
投票

[抱歉,我对python一无所知,但是在cmd中,引号引起了问题。在命令中将引号更改为使用双引号而不是单引号。在cmd中,单引号未被识别为有效的引号,因此,您的命令中的字符<>是从带引号的字符串中找到的,并被视为命令的一部分,即重定向。

command = r'confluence --action storePage --space "EN" --title "csoap-235" --parent "@home" --special " # ~" --content "<p><ac:link><ri:page ri:content-title=~Home~/></ac:link></p>" --noConvert --server "server" --user "username" --password "pswd"' 
os.system(command)
print "This happened"

未经测试,根据文档/样本编写。

© www.soinside.com 2019 - 2024. All rights reserved.