x,= y(???) [英] x, = y (???)

查看:66
本文介绍了x,= y(???)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我刚刚遇到了表格的分配


x,= y


其中y是一个字符串(如果它很重要)。


1.作业LHS中逗号的含义是什么?

2.如何我可以自己发现这个吗?


(关于上面的(2),我查阅了几本Python

参考书的索引,但我不能找到(1)的答案。我希望

找到更好的Python参考!)


TIA!


kynn


-

注意:在我的地址中,第一期之前的所有内容都是倒退的;

和最后一期,以及之后的所有内容都应该被丢弃。


I just came across an assignment of the form

x, = y

where y is a string (in case it matters).

1. What''s the meaning of the comma in the LHS of the assignment?
2. How could I have found this out on my own?

(Regarding (2) above, I consulted the index of several Python
reference books but I could not find the answer to (1). I hope to
find a better Python reference!)

TIA!

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.

推荐答案

kj写道:
kj wrote:

我刚刚遇到了一个表格的分配


x,= y


其中y是一个字符串(如果重要的话)。 />

1.什么是m LHS中逗号的逗号是什么?

2.我怎么能自己发现这个?


(关于上述(2) ,我查阅了几本Python

参考书的索引,但我找不到(1)的答案。我希望

找到一个更好的Python参考!)
I just came across an assignment of the form

x, = y

where y is a string (in case it matters).

1. What''s the meaning of the comma in the LHS of the assignment?
2. How could I have found this out on my own?

(Regarding (2) above, I consulted the index of several Python
reference books but I could not find the answer to (1). I hope to
find a better Python reference!)



这是打开一个1元组:


(x,)= y


此处的括号不是必需的,有时会被遗漏。


-

Erik Max Francis&& ma*@alcyone.com && http://www.alcyone.com/max/

美国加利福尼亚州圣何塞市&& 37 18 N 121 57 W&& AIM,Y!M erikmaxfrancis

美国虽然希望在没有国家的情况下进行战争,但是没有国家会购买和平的b $ b。 - James Madison

It''s unpacking a 1-tuple:

(x,) = y

The parentheses here are not necessary and are sometimes left out.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
The United States, while they wish for war with no nation, will buy
peace with none. -- James Madison


In< cr *************************** ***@speakeasy.netEri k Max Francis< ma*@alcyone.comwrites:
In <cr******************************@speakeasy.netEri k Max Francis <ma*@alcyone.comwrites:

> kj写道:
>kj wrote:


>我刚刚遇到了一个表格的分配

x,= y

其中y是一个字符串(如果重要的话)。

1。 LHS中逗号的逗号含义是什么?
>I just came across an assignment of the form

x, = y

where y is a string (in case it matters).

1. What''s the meaning of the comma in the LHS of the assignment?


>它正在解包1元组:
>It''s unpacking a 1-tuple:


> (x,)= y
> (x,) = y


>此处的括号不是必需的,有时会被遗漏。
>The parentheses here are not necessary and are sometimes left out.



我仍​​然没有得到它。如果我们写了


y =''Y''

x,= y


有什么区别现在介于x和y之间?如果没有

的差异,那么执行此类解包的重点是什么?


TIA!
< br $>
kynn

-

注意:在我的地址中,第一期之前的所有内容都是倒退的;

和最后一位期间以及之后的所有内容都应该被丢弃。

I still don''t get it. If we write

y = ''Y''
x, = y

what''s the difference now between x and y? And if there''s no
difference, what''s the point of performing such "unpacking"?

TIA!

kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


7月17日,12:55 * pm,kj< so ... @ 987jk.com.invalidwrote:
On Jul 17, 12:55*pm, kj <so...@987jk.com.invalidwrote:

我仍​​然没有得到它。 *如果我们写的话


* y * =''Y''

* x,= y


现在x和y之间有什么区别? *如果没有

的差异,那么执行此类解包的重点是什么?
I still don''t get it. *If we write

* y *= ''Y''
* x, = y

what''s the difference now between x and y? *And if there''s no
difference, what''s the point of performing such "unpacking"?



尝试:


y =" abc"

x,= y


你正打开y(''Y' ',)

Try:

y = "abc"
x, = y

You were unpacking y into (''Y'',)


这篇关于x,= y(???)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆