python双击py一闪_Python脚本在双击.py时无法正常运行
发布日期:2021-06-24 16:33:13 浏览次数:3 分类:技术文章

本文共 1506 字,大约阅读时间需要 5 分钟。

我在Python和编程方面是个半文盲,但是当我双击打开.py文件时,我的程序就不能正常工作了。当我通过IDE(Pycharm)从命令行运行它时,它就会出现。基本上,当双击时,它将到达key=input(“Enter-decode key:”)部分,键入内容后,它将关闭。任何帮助都将不胜感激。我知道我的代码并不优雅,它只是需要工作。Python 3.5.2

如果有帮助,“key”的示例输入将是23,而“encoded”的示例输入是142128133123134142。它应该输出“window”,并在命令行和Pycharm中成功输出。在import sys

def main(key, encoded):

if encoded == 0: #This should run if program was double-clicked (no arguments)

encoded = input("Paste encoded JavaScript: ")

key = input("Enter decode key: ")

def decode(key, encoded): #Decode the data

encoded = encoded.split(',') #Split each section delimiting by a colon

decoded = []

for x in encoded:

x = int(x) - int(key) #Subtract the key from the number in each section

decoded.append(chr(x)) #Change from ASCII decimal code to the ASCII character

decoded = ''.join(decoded) #Join back into a string

print(".")

print(".")

print(".")

print(".")

print("Encoded data:")

print(encoded)

print("Decode key:")

print(key)

print("Decoded data:")

print(decoded)

return 0

decode(key, encoded) #Jump into the decode function

return 0

if __name__ == "__main__":

try:

if len(sys.argv) > 1: #If length is greater than 1, then there were arguments added upon program execution

key = sys.argv[1] #The "key" should be the first argument

encoded = sys.argv[2] #The "encoded" data should follow

else:

key = 0 #If length is anything else, then set them to 0 and ask for the data later

encoded = 0

main(key, encoded) #Jump into main function and pass the key and encoded arguments

finally:

input("Press Enter to exit")

转载地址:https://blog.csdn.net/weixin_33865450/article/details/113508788 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:redis logfile为空_关于Redis(二)
下一篇:python bottle部署_nginx+uwsgi+bottle python服务器部署

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月18日 06时07分46秒