在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一无所知,但是在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"
未经测试,根据文档/样本编写。