Python Bash或GoogleCL:字符串参数中的新行

Python Bash或GoogleCL:字符串参数中的新行,python,bash,command-line,Python,Bash,Command Line,嗨,我正在使用上传视频到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." 摘要页

嗨,我正在使用上传视频到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知道如何处理多行字符串,只要按下中间的Enter就可以了。
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."

只要在绳子的边上放一条新线就行了。BASH知道如何处理多行字符串,只要按下中间的Enter就可以了。
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."

googlecl是一个python应用程序。用
\
逃离
\n
并将您的字符串设置为
“可怜的胡须会掉下来。\\n她很好…”
。这或许会有所帮助。

谷歌cl是一个python应用程序。用
\
逃离
\n
并将您的字符串设置为
“可怜的胡须会掉下来。\\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.'
您可以使用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.'

为了避免水平滚动,我很想将其格式化得更好,但我认为这会偏离答案的要点。“只需在字符串的边上添加一个实际的换行符。”???怎样当我按下“Enter”键时,命令将运行并发出错误。键入命令时,按下“回车”键。很抱歉。@DocWiki:您是否可能将命令粘贴到命令行中,然后移到字符串的中间并按enter键?如果您这样做,Bash将自动执行该命令。(即使你粘贴除最后一个引号之外的所有内容,然后移动到行中的适当位置并按enter键,你仍然无法在想要的位置获得换行。)@DocWiki:但是,如果你只粘贴换行符之前的内容(确保保留不匹配的引号),然后按enter键,然后键入/粘贴命令的其余部分,在这种情况下,你会在字符串中间得到一个换行符。我想把它格式化得更好,以避免水平滚动,但是我想它会减损答案的要点。“只要在字符串的旁边放一个锐利的换行符。”???怎样当我按下“Enter”键时,命令将运行并发出错误。键入命令时,按下“回车”键。很抱歉。@DocWiki:您是否可能将命令粘贴到命令行中,然后移到字符串的中间并按enter键?如果您这样做,Bash将自动执行该命令。(即使你粘贴除最后一个引号之外的所有内容,然后移动到行中的适当位置并按enter键,你仍然无法在想要的位置获得换行。)@DocWiki:但是,如果你只粘贴换行符之前的内容(确保保留不匹配的引号),然后按enter键,然后键入/粘贴命令的其余部分,在这种情况下,你会在字符串中间得到一个换行符。你能看一下这个问题:你能看一下这个问题: