Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 在Jython Sikulix中将字符串添加到一起的奇怪问题_Python 2.7_Jython_Sikuli - Fatal编程技术网

Python 2.7 在Jython Sikulix中将字符串添加到一起的奇怪问题

Python 2.7 在Jython Sikulix中将字符串添加到一起的奇怪问题,python-2.7,jython,sikuli,Python 2.7,Jython,Sikuli,因此,我正在用Jython SikuliX编写一个程序,通过采用三个字母的输入(MAG),然后在末尾(1)添加一个数字,然后为每个标签(MAG1-MAG2-MAG3等)将数字增加+1来自动制作标签 然而,这里的技巧是,我需要字母和数字的组合长度始终为6个字符(所以MAG001或MAG010或MAG100) 我已经得到了数字串联下来,但我遇到了一个奇怪的问题,任何数字超过100。从标签9到标签10及以上可以很好地工作(MAG009-MAG010-MAG011等),但是当我到达MAG99,然后转到M

因此,我正在用Jython SikuliX编写一个程序,通过采用三个字母的输入(MAG),然后在末尾(1)添加一个数字,然后为每个标签(MAG1-MAG2-MAG3等)将数字增加+1来自动制作标签

然而,这里的技巧是,我需要字母和数字的组合长度始终为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)

任何帮助都将不胜感激。

不管怎样,我解决了自己的问题:

我回到了一个不涉及函数的旧版本,并为name指定了一个变量,如果它已经有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