小编Zha*_*all的帖子

Python:在函数中使用局部变量,从函数返回变量

我正在尝试创建一个设置局部变量的脚本,从函数中引用它,并且可以将操作值返回到主范围(或者它的任何调用;我是Python的新手)

我已经简化了我的代码,以显示我想要完成的最基本的操作,即从模块将局部导入到功能块中,我想.

我已经通过使用来实现这一点globals,但这不是最好的解决方案...

chambersinreactor = 0;
cardsdiscarded = 0;

def find_chamber_discard(): 
    """Find chambers and discard in row (reads each player slot)"""
    chambersinreactor = 0; # Resets the variable, not what I want
    cardsdiscarded = 0; # Resets the variable, not what I want
    chambersinreactor += 1
    cardsdiscarded += 1
    return # Don't know what to put here

find_chamber_discard()

print chambersinreactor # prints as 0, should be 1
print cardsdiscarded    # prints as 0, should be 1
Run Code Online (Sandbox Code Playgroud)

python variables return function

7
推荐指数
1
解决办法
7万
查看次数

HTML-CSS跨浏览器颜色问题

我在html页面中使用以下CSS代码以设置H1和H2颜色值.

<style type="text/css">
img
{border-style: none;}
H1 {color: "#33CCFF"}
H2 {color: "#33CCFF"}
</style>
Run Code Online (Sandbox Code Playgroud)

这适用于Internet Explorer,但Chrome,Safari和Firefox都失败了.

如何解决此问题以支持所有浏览器?

谢谢

html css colors cross-browser

1
推荐指数
1
解决办法
279
查看次数

标签 统计

colors ×1

cross-browser ×1

css ×1

function ×1

html ×1

python ×1

return ×1

variables ×1