简体   繁体   English

反转 Python 脚本

[英]Reverse Python Script

[enter image description here][1]I created a script whereas the output should be "ACER,ONE" however I am stuck how can I place a reverse the username which I ended up "ONE,ACER" as result. [在此处输入图片描述][1] 我创建了一个脚本,而 output 应该是“ACER,ONE”,但是我不知道如何放置一个反转的用户名,结果我最终变成了“ONE,ACER”。

email='one.acer@mymail.com'
index = email.index("@")
email_id = email[:index]
email_id = email_id.upper()
print(email_id.replace(email_id[3],","))
",".join("ACER,ONE".split(",")[::-1])

In your case, you could do:在你的情况下,你可以这样做:

print(",".join(email.split("@")[0].split(",")[::-1]))

as @ox5453 mentioned in the comments, you can also use the built-in reversed method for readability:正如@ox5453 在评论中提到的那样,您还可以使用内置的 reversed 方法来提高可读性:

print(",".join(reversed("ACER,ONE".split(","))))
print(",".join(reversed(email.split("@")[0].split(","))))
email1 ='one.acer@mymail.com'
email2 = print(",".join(reversed("ONE,ACER".split(","))))

This is my answer which I got ACER,ONE这是我得到的答案 ACER,ONE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM