Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Jython 脚本中,我试图用包含变量 (VAR) 的目录地址替换文本文件的整行(在本例中为第二行)。
obsids=str(obsids[i]) print type(obsids) os.system('sed -i "2 s:.*:/usr/data/$obsids/:" /usr/software/file.txt')
哪里obsids是一个整数的 unicode,然后是一个字符串(通常类似于 1342204440)。
obsids
请你告诉我我的脚本中的错误。
谢谢。
我们在评论中得到了它:
obsids=str(obsids[i]) print type(obsids) os.environ['obsids']=obsids # this makes the Python variable behave inside UNIX os.system('sed -i "2 s:.*:/usr/data/$obsids/:" /usr/software/file.txt')