我准备了一些代码来执行这样的命令行:
c:cygwinbinconvert "c:rootdropBoxwwwtiffphotosarchitecturecalendar-bwl-projektbwl01.tif" -thumbnail 352x352^ -format jpg -filter Catrom -unsharp 0x1 "c:rootdropBoxwwwtiffthumbnailsarchitecturecalendar-bwl-projektthumbnailbwl01.jpg"
这从命令行工作正常(同上面的命令),但352×352 ^是352×352 ^不是352×352:
c:cygwinbinconvert "c:rootdropBoxwwwtiffphotosarchitecturecalendar-bwl-projektbwl01.tif" -thumbnail 352x352^ -format jpg -filter Catrom -unsharp 0x1 "c:rootdropBoxwwwtiffthumbnailsarchitecturecalendar-bwl-projektthumbnailbwl01.jpg"
如果从python运行这个代码 – 字符'^'被忽略,resize的图像的大小为'%sx%s'被传递不是%sx%s ^ – 为什么Python剪切'^'字符以及如何避免? :
def resize_image_to_jpg(input_file,output_file,size): resize_command = 'c:\cygwin\bin\convert "%s" -thumbnail %sx%s^ -format jpg -filter Catrom -unsharp 0x1 "%s"' % (input_file,size,output_file) print resize_command resize = subprocess.Popen(resize_command) resize.wait()
从ffserver开始stream简单mp4
Python子stream程Popen:在Windows上将二进制数据发送到C ++
服务器cpu和GPU与LAMP
为什么涓stream实用程序不会影响我的dynamic链接的golang程序?
使用Vagrant从configurationshell脚本更新.bashrc
为什么开始stream式查询会导致“ExitCodeException exitCode = -1073741515”?
如何在PuPHPet生成的configuration文件中设置Nginx重写规则?
Java似乎正在发送回车到一个subprocess?
在Windows上安装Airflow
木偶失败:无法分配内存 – 叉(2)
为什么Python会削减“^”字符以及如何避免?
Python不会剪切^字符。 Popen()将字符串( resize_command Popen()传递给CreateProcess() Windows API调用。
这很容易测试:
#!/usr/bin/env python import sys import subprocess subprocess.check_call([sys.executable,'-c','import sys; print(sys.argv)'] + ['^','<-- see,it is still here'])
后面的命令使用subprocess.list2cmdline() ,它遵循Parsing C Command-Line Arguments规则将列表转换为命令字符串 – 它对^没有影响。
^对于CreateProcess()不是特别的。 如果你使用shell=True (当cmd.exe运行时) ^是特殊的 。
当且仅当生成的命令行将被cmd解释时,用^字符作为每个shell元字符(或每个字符)的前缀 。 它包括^本身。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。