且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ruby%w等价物

更新时间:2022-06-13 15:16:41

Antoine De Groote写道:
Antoine De Groote wrote:

>

有一个等效于ruby%的python w运算符?
>
is there a python equivalent for the ruby %w operator?
%w{a b c} creates an array with strings "a", "b", and "c" in ruby...



| >>" a b c" .split()

| ['''',''b'',''c'']


....似乎与你的单个例子相符。


HTH,

John

| >>"a b c".split()
| [''a'', ''b'', ''c'']

.... appears to match your single example.

HTH,
John


ruby​​%w运算符是否有python等价物?
is there a python equivalent for the ruby %w operator?

%w {a b c}创建一个包含字符串a,b和c的数组。在ruby ...
%w{a b c} creates an array with strings "a", "b", and "c" in ruby...



表达式''ab c''。split()创建['''',''b'','' c''] str的列表,

如果有帮助的话。


dir(''ab c'')也简要列出了很多
http://docs.python.org/lib/string-methods .html 解释。


此外,谷歌还好奇地告诉我Ruby的'%w是

记录在哪里。


Pat LaVarre

The expression ''a b c''.split() creates the [''a'', ''b'', ''c''] list of str,
if that helps.

Also dir(''a b c'') briefly lists much of what
http://docs.python.org/lib/string-methods.html explains.

Also Google was curiously resistant to telling me where Ruby''s %w is
documented.

Pat LaVarre



p。******* @ ieee.org 写道:

>

此外,谷歌还好奇地告诉我,Ruby的'%w是

记录在哪里。
>
Also Google was curiously resistant to telling me where Ruby''s %w is
documented.



你需要挖掘你的谷歌工具栏配置和取消勾选

YAGNI过滤器。

You would need to dig into your Google toolbar config and un-tick
"YAGNI filter".