[英]syntax error near unexpected token `<' from Applescript to Python
I am using the following command to pass a string to python from Applescript我正在使用以下命令将字符串从 Applescript 传递给 python
String mytext contains the HTML body of an email starting with <...字符串 mytext 包含以 <...
Applescript Applescript
display dialog (do shell script "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/ test.py" & mytext)
Python Python
#!/usr/bin/env python
import sys
import string
def main():
print sys.argv[1:]
if __name__ == "__main__":
main()
How can I rectify this error?我该如何纠正这个错误?
You don't want to pass the HTML as an argument to the Python script.您不想将 HTML 作为参数传递给 Python 脚本。 Instead, do something like:
相反,请执行以下操作:
display dialog (do shell script "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/ test.py < webpage.html")
print sys.stdin.read()
The problem is you are executing a shell script... by constructing a long line of text.问题是您正在执行 shell 脚本...通过构造一长行文本。 "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/ test.py" & "... ")
"/Users/mymac/Documents/'Microsoft 用户数据'/'Outlook 脚本菜单项'/test.py" & "...")
but the "<" sign and the ">" sign have a special meaning for the shell.但“<”符号和“>”符号对于 shell 具有特殊含义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.