py文件打包成exe,输入一些简单的信息,然后结束

环境,win10、anaconda2 ,(并存anaconda3)参考“https://blog.csdn.net/qq_15192373/article/details/78572885”win10。笨办法写了一个简单的交互程序,我想把它变成exe可执行文件,这样可以给别人也用。

用到的包:Pyinstaller 用 pip install pyinstaller 

打包:pyinstaller -F 00.py

打包的时候可以先切到 .py文件所在的目录

 1 # -*- coding:utf-8 -*-
 2 from sys import argv
 3 
 4 print "Please write you name and sexual (man or women)"
 5 user_name = raw_input("What's your name ?")
 6 user_sex  = raw_input("what's your sexual ?")
 7 script = argv
 8 prompt = 'please write here: '
 9 print "Hi %s ,I'm the %s script "%(user_name,script )
10 print "I'd like to ask you a few question "
11 
12 print "Do you like me %s "%user_name
13 likes = raw_input(prompt)
14 
15 print "where do you live %s "%user_name
16 lives =raw_input(prompt)
17 
18 print "What kind of computer do you have?"
19 computer = raw_input(prompt)
20 
21 if user_sex=='man':
22     
23     man  = 'man'
24 else:
25     women ='women'    
26 print """
27 Alright ,you said %r about liking me .you are 
28 good %s .you live in %r .Not sure where that is .
29 And you have a %r computer .Nice.
30 """%(likes ,user_sex,lives ,computer )
31 print "please input any key exit()"
32 raw_input()

这一节是练习 argv,但是打包成exe,在运行的时候并没有传入参数,所以我就让它只接受自己这个参数,然后再做一些简单的交互。

打包完新增的文件有这几个。参考“https://jingyan.baidu.com/article/a378c960b47034b3282830bb.html”

 

然后就开始运行啦!exe文件在dist文件夹里。

woman还写成了负数,sorry。

 这么几行,打包完还好几兆,看来还是要研究。

 

posted @ 2018-11-20 18:11  羊小姐  阅读(350)  评论(1编辑  收藏  举报