我正在尝试<body>在CSS 中设置外部标记的背景图像:
<html>
<body>
...
#document
<html>
<body>
</body>
</html>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,我甚至无法选择其中一个<body>标签而不影响另一个标签.他们没有身份证,当我尝试通过儿童选择器选择#document使事情变得复杂时(我甚至不知道它是什么).如果我尝试类似的东西body html body {...},这些#document行为就像一个我无法通过的障碍,所以它不会选择内部身体标签.
有关如何选择其中一个身体标签的任何想法?
我编写了一个函数,它迭代计算一些数量X,Y,返回最终结果。此外,此代码将每次迭代保存X,Y到文件中。这是基本结构:
def myFunc():
X,Y = 0,0
file1 = open(output1,"w")
file2 = open(output2,"w")
for i in range(1000):
X,Y = someCalculation(X,Y) #calculations happen here
file1.write(X)
file2.write(Y)
file1.close()
file2.close()
return X,Y
Run Code Online (Sandbox Code Playgroud)
但是,如果调用函数时省略文件名output1或,我需要此函数执行相同的计算,而不向相关文件添加任何内容。output2
这是我的凌乱的解决方案:
def myFunc(output1=None,output2=None):
X,Y = 0,0
if (output1 != None): file1 = open(output1,"w")
if (output2 != None): file2 = open(output2,"w")
for i in range(1000):
X,Y = someCalculation(X,Y) #calculations happen here
if (output1 != None): file1.write(X)
if (output2 != None): file2.write(Y)
if (output1 …Run Code Online (Sandbox Code Playgroud)