Bash或GoogleCL:字符串参数中的换行符
嗨,我正在使用GoogleCL 版本 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"没有起作用。谁能帮我解决这个问题?
非常感谢!
3 个回答
0
googlecl是一个用Python写的应用程序。如果你想在字符串中使用换行符\n
,需要在它前面加一个反斜杠\
,这样你的字符串就变成了"Poor whiskers takes a tumble.\\nShe's fine..."
。这样做可能会对你有帮助。
1
只需在字符串中放入一个实际的换行符。Bash(一个常用的命令行工具)知道如何处理多行字符串,只要你在它们中间按一下回车键就可以了。
google youtube post ~/videos/cat-falls-down-stairs.avi Comedy --tags "currency of the internet" --summary "Poor whiskers takes a tumble.
She's fine, though, don't worry."
9
你可以使用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.'