2017-06-06 60 views
0

因此,我正在使用Jython SikuliX編寫一個程序,通過輸入三個字母輸入(MAG),然後向末尾添加數字(1)然後遞增數字對每個標籤(MAG1 - MAG2 - MAG3等)+1 +1在Jython中添加字符串的奇怪問題Sikulix

然而,這裏的技巧是我需要字母和數字的組合總是6個字符的長度(所以MAG001或MAG010或MAG100)。

我已經得到了數字連接,但是我遇到了一個超過100的任何數字的奇怪問題。從標籤9到標籤10以及上面的工作完美(MAG009 - MAG010 - MAG011等)當我到達MAG99然後去MAG100我收到一個錯誤:

[error] --- Traceback --- error source first line: module (function) 
statement 26: main (name_change) name = name 
[error] --- Traceback --- end -------------- 

我不知道這是爲什麼...代碼如下。

import time 

name1 = str(input("First three letters of product name")) 
labels = int(input("At what number do you want the labels to stop?")) 

a = int(input("What number should the labels start at?")) 
e = "00" 
d = "0" 



find("1496686601617.png") 
doubleClick("1496686607803.png") 

def name_change(name1, a): 
    a = str(a) 
    c = len("%s%s" % (name1, a)) 

    if c == 4: 
     name = ("%s%s" % (name1, e)) 

    if c == 5: 
     name = ("%s%s" % (name1, d)) 

    if c == 6: 
     name = name 

    a = int(a) 
    return name 

def label_make(name, a): 
    click("1496688531026.png") 
    type("0000") 
    rightClick("1496688447045.png") 
    click("Select_All.png") 
    type("%s%r" % (name, a)) 
    click("1496686753618.png") 
    click("Save As-1.png") 
    time.sleep(1) 
    type("%s%r" % (name, a)) 
    click("1496687258684.png") 

    a = a + 1 
    return a 

while labels >= a: 
    name = name_change(name1, a) 
    a = label_make(name, a) 

任何幫助將不勝感激。

回答

0

沒關係,我解決我自己的問題:

我就回不涉及功能和指定的變量名稱,如果它已經是6個字符長,它的工作原理是舊版本。以下代碼:

import time 

name1 = str(input("First three letters of product name")) 
labels = int(input("At what number do you want the labels to stop?")) 

a = int(input("What number should the labels start at?")) 
e = "00" 
d = "0" 



find("1496686601617.png") 
doubleClick("1496686607803.png") 

while labels >= a: 
    #a = str(a) 
    c = len("%s%s" % (name1, a)) 

    if c == 4: 
     name = ("%s%s" % (name1, e)) 

    if c == 5: 
     name = ("%s%s" % (name1, d)) 

    if c == 6: 
     name = name1 

    #a = int(a) 


    click("1496688531026.png") 
    type("0000") 
    rightClick("1496688447045.png") 
    click("Select_All.png") 
    type("%s%r" % (name, a)) 
    click("1496686753618.png") 
    click("Save As-1.png") 
    time.sleep(1) 
    type("%s%r" % (name, a)) 
    click("1496687258684.png") 
    #a = int(a) 
    a = a + 1