我使用find命令在一个文件夹中查找所有python文件,并排除了一些文件夹。
guess
给出以下输出:
except
如何调整from graphics import *
import random
hidden = random.randrange(1, 10)
def response_dict():
return {
'high': 'woah! you are too high!',
'low': 'oh no! that is too low',
'equal': 'yes, this is just right!',
'none': 'It is not number',
}
def circles():
win = GraphWin("Random Circles",300,300)
for i in range(300):
r = random.randrange(256)
b = random.randrange(256)
g = random.randrange(256)
color = color_rgb(r, g, b)
radius = random.randrange(3, 40)
x = random.randrange(5, 295)
y = random.randrange(5, 295)
circle = Circle(Point(x, y), radius)
circle.setFill(color)
circle.draw(win)
time.sleep(.05)
def textBox(win):
message = Text(Point(250,50),'Please guess a number 1 through 10 then click outside the box')
message.draw(win)
message2 = Text(Point(250,100),'You have 4 tries, to guess the number correctly.')
message2.draw(win)
# you can get it once
levels = response_dict()
# 4 tries
for i in range(4):
textEntry = Entry(Point(233,200),10)
textEntry.draw(win)
win.getMouse()
# get number
number = textEntry.getText()
try:
guess = int(number)
print(guess)
except Exception as ex:
#print(ex)
guess = None
# hide entry - so user can't put new number
textEntry.undraw()
if guess is None:
# show message
response = Text(Point(300,300), levels['none'])
response.draw(win)
elif guess < hidden:
# show message
response = Text(Point(300,300), levels['low'])
response.draw(win)
elif guess > hidden:
# show message
response = Text(Point(350, 350), levels['high'])
response.draw(win)
else:
response = Text(Point(300, 300), levels['equal'])
response.draw(win)
win.getMouse()
circles()
break # exit loop
again = Text(Point(400,400), 'Guess again, click mouse.')
again.draw(win)
# wait for mouse click
win.getMouse()
# remove messages
response.undraw()
again.undraw()
# --- main ----
win = GraphWin('guess number', 700, 700)
win.setBackground('brown')
textBox(win)
exitText = Text(Point(400, 400), 'Click anywhere to quit')
exitText.draw(win)
win.getMouse()
win.close()
命令以在结果集中排除./venv?
答案 0 :(得分:1)
如果您未指定任何操作,则find
将对与您的表达式匹配的任何文件隐式使用-print
。 -prune
始终评估为true(除了防止进一步递归),这就是./venv
仍然最终被打印的原因。
为避免这种情况,只需将-print
添加到另一个分支:
find . -type d \( -path ./venv -o -path ./virtualenv -o -path ./lib \) -prune \
-o -iname '*.py' -print
现在有一个动作,因此find
不再打印会被评估为true的所有内容,而是仅打印您明确查找的文件。