delete a specific character

Asked by Ju1+i-我. on 2018-12-20

python , determines whether a string contains a specific Chinese character, if so, then deletes it

but it doesn't work :

            value = unicode(Env.getClipboard(),'utf-8')
            wait(1)
            t = unicode("英博",'utf-8')
            wait(1)
            #str.find(str, beg=0, end=len(string))
            if t in value :
                value2 = value.replace(t,"")
                wait(1)
                click("1545288319341.png")
                wait(1)
                type(Key.TAB)
                wait(1)
                paste(value2)

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-12-29
Last query:
2018-12-29
Last reply:
2018-12-20
RaiMan (raimund-hocke) said : #1

tested on Mac. this works for me:

t = u"英博英博英博英博"
x = u"英"
uprint(t)
uprint(x)
uprint(t.replace(x, ""))
App.open("textedit")
wait(1)
paste("paste:\n")
paste(t.replace(x, ""))

print out:
英博英博英博英博

博博博博

pasted:
paste:
博博博博

Best RaiMan (raimund-hocke) said : #2

this might be relevant for you gnerally:
https://docs.python.org/2/howto/unicode.html#the-unicode-type

Ju1+i-我. (1ju2+i-a.) said : #3

Thanks RaiMan, that solved my question.