在python中用表情符号替换一些表情符号

6uxekuva  于 2022-12-28  发布在  Python
关注(0)|答案(3)|浏览(206)

这是我的代码现在的样子。当用户输入一个句子或单词时,我想把表情符号改为表情符号。我该怎么做呢?

def main():
    sentence = input("Input a Sentence: ")
    convert(sentence)
    print(sentence)

def convert():
    emo1 = ":)"
    emo2 = ":("
    emo1.replace(":)", "🙂")
    emo2.replace(":(", "🙁")

main()
dkqlctbz

dkqlctbz1#

您需要在发送到function convert的句子中添加替换图释。

def main():
    sentence = input("Input a Sentence: ")
    print(sentence)
    sentence = convert(sentence)
    print(sentence)

def convert(sentence):
    sentence = sentence.replace(":)", "🙂")
    sentence = sentence.replace(":(", "🙁")
    return sentence

main()
a64a0gku

a64a0gku2#

def main():#用户输入

variable_faces = input("Enter your sentence or word: ")
print(change_faces(variable_faces))

def change_faces(sentence): sentence = sentence.replace(":)", "🙂") sentence = sentence.replace(":(", "🙁")

return sentence

主()

o2rvlv0m

o2rvlv0m3#

工作就像一个魅力

def主文件():

x = input('Type: ')
print(convert(x))

def转换(x):

x=x.replace(':)', '🙂')
x=x.replace(':(', '🙁')
return x

主()

相关问题