Skip to main content
 首页 » 编程设计

python之Bash 或 GoogleCL : new line in a string parameter

2025年05月04日10zengkefu

嗨,我正在使用 GoogleCL version 0.9.11将视频上传到 Youtube。我的操作系统是 CentOS 5.5 和 Python 2.5。

其中一个字符串参数包含换行“\n”,无法正常显示。

google youtube post ~/videos/cat-falls-down-stairs.avi Comedy --tags "currency of the internet" --summary "Poor whiskers takes a tumble.\nShe's fine, though, don't worry." 

摘要页面显示为:

Poor whiskers takes a tumble.\nShe's fine, though, don't worry. 

但是我想要:

Poor whiskers takes a tumble. 
She's fine, though, don't worry. 

“\n”不起作用。谁有解决办法?

非常感谢!

请您参考如下方法:

您可以使用 Bash 的 $''构造以在将转义序列传递给 googlecl 之前扩展转义序列。

google youtube post ~/videos/cat-falls-down-stairs.avi Comedy \ 
    --tags 'currency of the internet' \ 
    --summary $'Poor whiskers takes a tumble.\nShe'\''s fine, though, don'\''t worry.'