国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Problem with python local variables
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-05-18 10:53:25
0
4
687

The digg_url in session.get is obviously None, but in fact, what I want to use is the above if...else statement. If in c, just declare digg_url above the if statement, but py cannot do this. Do.

Of course, to solve my problem, I can move session.get into the if statement, but if I think about it, what if there are dozens of statements like session.get that reference digg_url?

So I want to ask how to solve this problem? (Can it only be set to global? I’m a bit speechless about this py)

PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證0級(jí)講師

reply all(4)
小葫蘆

You can directly use variables defined in if-else in Python

For example

# 前面并沒(méi)有使用過(guò)b
if a == 1:
    b = 2
else:
    b = 1
print(b) #完全合法

Yourssession.get中的digg_url不應(yīng)該是None, you can export it and take a look.

洪濤

Although I'm not very familiar with python, maybe it's possible to assign an arbitrary value to digg_url before the if?

習(xí)慣沉默

You can define on if

digg_url = None

Or use the ternary operator

digg_url = 'a' if digg else 'b'
給我你的懷抱

It is recommended that you print out digg_url and session before using get. I think your logic is wrong. And what are the four and two parameter headers in get used for?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template