我正在使用漂亮的表格来生成表格输出。
是否可以根据颜色生成。如果失败,它应该显示为红色,正常它应该显示为绿色。
代码:
from prettytable import PrettyTable
a = "ok"
b = "Failed"
t = PrettyTable(['Input', 'status'])
if a == "ok":
t.add_row(['FAN', a])
else:
t.add_row(['FAN', b])
print t
Run Code Online (Sandbox Code Playgroud) 这是进度旋转器的代码:
import sys
import time
def spinning_cursor():
while True:
for cursor in '|/-\\':
yield cursor
spinner = spinning_cursor()
for _ in range(50):
sys.stdout.write(spinner.next())
sys.stdout.flush()
time.sleep(10)
sys.stdout.write('\b')
Run Code Online (Sandbox Code Playgroud)
输出
python2.7 test.py
|
Run Code Online (Sandbox Code Playgroud)
由于循环休眠了 10 秒,它的旋转速度非常慢......
如何在进程休眠时继续旋转旋转器?
我有下面的代码:
a = 1
b = 2
c = 3
d = 4
e = 5
if ((a == 1 and
b == 2 and
c == 4) or
(d == 4 and e == 5)):
print "Yeah, Working"
else:
print "ooops"
Run Code Online (Sandbox Code Playgroud)
可以实现相同的代码简单和最好的方法吗?
我是Jenkins和Python的新手。我有詹金斯测试构建项目与构建参数。以下是参考屏幕截图。
我需要将此输入传递给python脚本“ test.py”
我的执行命令如下所示:
/usr/bin/python2.7 /scripts/test.py
Run Code Online (Sandbox Code Playgroud)
test.py脚本:
import time
import os
input1 = os.getenv("input1")
input2 = os.getenv("input2")
Dropdown = os.getenv("Dropdown1")
Dropdown2 = os.getenv("Dropdown2")
print input1
print input2
print Dropdown
print Dropdown2
Run Code Online (Sandbox Code Playgroud)
控制台输出:
Building in workspace /root/.jenkins/workspace/Inputs-Test
[Inputs-Test] $ /bin/sh -xe /tools/apache-tomcat-8.5.24/temp/jenkins3261310337115825812.sh
+ /usr/bin/python2.7 /project/test.py
None
None
None
None
Finished: SUCCESS
Run Code Online (Sandbox Code Playgroud) >>> oranges = "10 100 200"
>>> oranges == "10 100 200"
False
>>> apples = "10 20 30"
>>> apples == "10 20 30"
True
Run Code Online (Sandbox Code Playgroud)
"10 100 200"在我的情况下,期望橙子的输出是真的.
我正在寻找是否按顺序存在10 100 200.我尝试了条带化,但它只会启动字符串和字符串的结尾.
我有两个清单
list1 = ['a', 'b', 'c']
list2 = [['a', 'b', 'c'], ['e', 'f', 'g']]
Run Code Online (Sandbox Code Playgroud)
现在我必须找到
Is list1 is list of list
Expected result "False"
Is list2 is list of list
Expected result is "True"
Run Code Online (Sandbox Code Playgroud)
如何实现这一目标