- 论坛徽章:
- 0
|
# Filename : aa.py
import appuifw
def xy(a,b):
x=((float(a[0])-float(b[0]))**2+(float(a[1])-float(b[1]))**2)**0.5
return x
a=appuifw.query(u'First point:','text')
b=appuifw.query(u'Second point:','text')
f = file('d:/abc.txt')
lines = f.readlines()
xx = [line.split(' ')[0] for line in lines]
if xx.count(a)>0 and xx.count(b)>0:
cf = xx.count(xx[xx.index(a)])
ct = xx.count(xx[xx.index(b)])
if cf > 1 or ct > 1:
appuifw.note(u'error: The numeral is redundant,please check files','error')
f.close()
yy = lines[xx.index(a)].split(' ')[1:]
yy1 = lines[xx.index(b)].split(' ')[1:]
appuifw.note(u'Distance ='+str(xy(yy,yy1)),'info')
else:
if xx.count(a)==0:
appuifw.note(u'error:'+a+u' NO find.','error')
if xx.count(b)==0:
appuifw.note(u'error:'+b+u' NO find.','error')
——————————————————
a、b是两个数字,我想把下面两个输入框合并成一个输入,比如“5 3”,然后在程序内部再分割开。
a=appuifw.query(u'First point:','text')
b=appuifw.query(u'Second point:','text')
采用下面的办法:
ab=appuifw.query(u'Two point:','text')
bb = [line.split(' ')[0] for line in ab]
a = bb[0]
b = bb[1]
但是得到的a b前后好像不大一样啊。 |
|