下面的Python语句的等效代码是什么?
我不明白这段代码到底是做什么的。有什么帮助吗 谢谢下面的Python语句的等效代码是什么?,python,if-statement,Python,If Statement,我不明白这段代码到底是做什么的。有什么帮助吗 谢谢 post_data = None if post_args is None else urllib.urlencode(post_args) 相当于以下内容: post_data = None if post_args is None else urllib.urlencode(post_args) 相当于以下内容: post_data = None if post_args is None else urllib.urlencode(po
post_data = None if post_args is None else urllib.urlencode(post_args)
相当于以下内容:
post_data = None if post_args is None else urllib.urlencode(post_args)
相当于以下内容:
post_data = None if post_args is None else urllib.urlencode(post_args)
这是一个在Python2.5中引入的。(它真的应该在一条线上)
如果post\u args为None
,则它会完全按照它的意思执行--post\u data
为None
,否则它会被分配urllib.urlencode(post\u args)
的结果
一种更为冗长的写作方式是
if post_args is None:
post_data = None
else:
post_data = urllib.urlencode(post_args)
或者,使用:
这是一个在Python2.5中引入的。(它真的应该在一条线上)
如果post\u args为None
,则它会完全按照它的意思执行--post\u data
为None
,否则它会被分配urllib.urlencode(post\u args)
的结果
一种更为冗长的写作方式是
if post_args is None:
post_data = None
else:
post_data = urllib.urlencode(post_args)
或者,使用:
照原样读……;-)照原样读……;-)