笨办法41学会说面向对象【pyinstaller安装使用
urllib库安装
先切换到pip所在目录
D:\Program Files\JetBrains\PyCharm 2017.3.3\untitled>cd /d c:\ c:\>cd c:\Users\ceshi\AppData\Local\Programs\Python\Python36\Scripts\
执行下载安装指令【哦 这里装了个exe打包工具 要装urllib的话 直接把名字改了就成
c:\Users\ceshi\AppData\Local\Programs\Python\Python36\Scripts>pip install Pyinstaller
以下是打包exe的,与urllib无关
c:\Users\ceshi\AppData\Local\Programs\Python\Python36\Scripts>pyinstaller.exe -F d:\pytest\gai.py
=============================================
课文内容待补
====================================
回来了。。
要被这节课搞疯 python2和python3的鸿沟 对于刚入门的小辣鸡来说实在是。。 心疼自己(ಥ_ಥ)
装的是python3.6.4
1 import random
2 from urllib import request #from urllib import urlopen
3 import sys
4
5 WORD_URL = "http://learncodethehardway.org/words.txt"
6 WORDS = []
7
8 PHRASES = {
9 "class %%%(%%%):":
10 "Make a class named %%% that is-a %%%.",
11 "class %%%(object):\n\tdef __init__(self, ***)" :
12 "class %%% has-a __init__ that takes seulf and *** parameters.",
13 "class %%%(object):\n\tdef ***(self, @@@)":
14 "class %%% has-a function named *** that takes self and @@@ parameters.",
15 "*** = %%%()":
16 "Set *** to an instance of class %%%.",
17 "***.***(@@@)":
18 "From *** get the *** function, and call it with parameters self, @@@.",
19 "***.*** = '***'":
20 "From *** get the *** attribute and set it to '***'."
21 }
22
23 # do they want to drill phrases first
24 if len(sys.argv) == 2 and sys.argv[1] == "english":
25 PHRASE_FIRST = True
26 else:
27 PHRASE_FIRST = False
28
29 # load up the words from the website
30 for word in request.urlopen(WORD_URL).readlines(): #for word in urlopen(WORD_URL).readlines():
31 WORDS.append(word.strip())
32
33 def convert(snippet, phrase):
34 class_names = [w.capitalize() for w in
35 random.sample(WORDS, snippet.count("%%%"))]
36 other_names = random.sample(WORDS, snippet.count("***"))
37 results = []
38 param_names = []
39
40 for i in range(0, snippet.count("@@@")):
41 param_count = random.randint(1,3)
42 param_names.append(', '.join(str(random.sample(WORDS, param_count)))) #param_names.append(', '.join(random.sample(WORDS, param_count)))
43
44 for sentence in snippet, phrase:
45 result = sentence[:]
46
47 # fake class names
48 for word in class_names:
49 result = result.replace("%%%", "word", 1) #result = result.replace("%%%", word, 1)
50
51 # fake other names
52 for word in other_names:
53 result = result.replace("***", "word", 1) #result = result.replace("***", word, 1)
54
55 # fake parameter lists
56 for word in param_names:
57 result = result.replace("@@@", word, 1)
58
59 results.append(result)
60
61 return results
62
63 # keep going until they hit CTRL-D
64 try:
65 while True:
66 snippets = list(PHRASES.keys())
67 random.shuffle(snippets)
68
69 for snippet in snippets:
70 phrase = PHRASES[snippet]
71 question, answer = convert(snippet, phrase)
72 if PHRASE_FIRST:
73 question, answer = answer, question
74
75 print(question)
76
77 input("> ")
78 print("ANSWER: %s\n\n" % answer)
79 except EOFError:
80 print("\nBye")
========================
绕得晕乎乎。。 最近转做发行运营公司的测试。 感觉原本仅存的脑子也被吃掉了 写在小本本上背吧。。
在左边有一个Python代码片段列表,右面是他们的解释
class X(Y):创建一个叫X的类,并继承Y
class X(object): def __init__(self, J):类X有一个__init__方法,该方法有self和J两个参数
class X(object): def M(self, J):类X有一个叫M的函数,该函数有self和J两个参数
foo = X():给foo赋值为类X的一个实例
foo.M(J):从foo里调用M函数,传递的参数为self和J
foo.K = Q:从foo里调用K属性,并将其设置为Q。
笨办法41学会说面向对象【pyinstaller安装使用的更多相关文章
- sql笨办法同步数据
Helpers.SqlHelper sqlHelper = new Helpers.SqlHelper("server=***;database=Cms;user id=sa;passwor ...
- 笨办法用js屏蔽被http劫持的浮动广告
最近发现网站经常在右下角弹出一个浮动广告,开始的时候以为只是浏览器的广告. 后来越来越多同事反映在家里不同浏览器也会出现广告.然后深入检查了下,发现网站竟然被劫持了. 然后百度了一大堆资料,什么htt ...
- Atom 安装 Packages 的笨办法
在终端里输入下面的命令打开 Atom 的 packages 的安装目录. open ~/.atom/packages 然后找到需要安装的 Atom packages ,比如我需要安装的这个 atom- ...
- PyInstaller 安装方法 及简单的编译exe (python3)
安装PyInstaller //地址 https://github.com/pyinstaller/pyinstaller/tree/python3 //上面的链接已经失效,新的(20160809更) ...
- 【PyInstaller安装及使用】将py程序转换成exe可执行程序
1 配置所需的环境 平台:windows7 64位,已经安装了python(x,y) 若未安装python环境,请自行安装python2.7或者其他版本,Python安装完成以后,需要将Python ...
- PyInstaller安装使用方法
PyInstaller可以把Python应用程序及其所有依赖项捆绑到一个包中.用户可以在不安装Python解释器或任何模块的情况下运行打包的应用程序.PyInstaller支持Python 2.7和P ...
- pyinstaller安装配置
一.工具准备: 1).安装pyinstaller需要以这个包为基础.也就是基础软件包.pyWin32包.下载对应的pyWin32安装包>>地址: https://sourceforge.n ...
- Pyinstaller安装以及参数使用
一.安装 pip install pyinstaller (注:win7系统安装有pywin32依赖包,先按pywin32在进行以上的步骤) 二.参数说明(这里要注意大小写) -F 表示生成单个可 ...
- pyinstaller安装及使用
pyinstaller使用 将.py文件转换成无需源码的.exe可执行文件 下载 1.打开cmd直接输入pip install pyinstaller即可下载 2.如第一种方法无法下载,打开pyins ...
随机推荐
- C++ STL标准容器插入删除算法的复杂度
1 vector内部实现: 数组 // 就是没有固定大小的数组,vector直接翻译是向量的意思支持操作:begin(), //取首个元素,返回一个iteratorend(), //取末尾(最后一个元 ...
- element-ui 解决 table 里包含表单验证的问题!
实际项目中的场景,需要在table里做表单的验证,如图效果: 其实问题关键就在于如何给el-form-item动态绑定prop :prop="'tableData.' + scope.$in ...
- Spring中三种编程式事务的使用
引入事务管理器 @Autowired TransactionTemplate transactionTemplate; @Autowired PlatformTransactionManager tr ...
- radhat6.6上安装oracle12c RAC (二)
二.GI(Grid Infrastructure)安装 首先将安装包传到node1的目录 2.1 GI软件安装 2.1.1.解压安装包 #su - grid解压 GRID 到 GRID用户的$ORAC ...
- python脚本练习之编译安装python
练习 py-shelll #coding=utf-8 import os,sys if os.getuid() == 0: pass else: print('当前用户不是root,请以root用户执 ...
- webdriver之select、alert、prompt、confirm
select_by_index() :通过索引定位select_by_value() :通过value值定位select_by_visible_text() :通过文本值定位deselect_al ...
- 关于win10环境下Anaconda python,用pip安装包及升级时SSL报错的问题
刚开始查完以为是网的问题,但是添加信任值\镜像网站\手动下载安装都失败了. 检查后发现python中无SSL模块,检查Anaconda后发现是少加了环境变量Anaconda3\Library\bin, ...
- python笔记---@classmethod @staticmethod
python定义类方法的三种方式: 1.常规方式--需要通过self参数隐式的传递当前类对象的实例 2.@classmethod修饰方式--@classmethod修饰的方法class_foo()需要 ...
- 记一次IIS发布网站导致系统时常跳入登录页面的问题解决
服务器:winserver2012R2 iis 发布网站后,正常浏览网页,时常跳到登录页面,第一反应session过期,因为登录信息都存在session,但session 都是默认配置过期时间为20分 ...
- 分布式拒绝服务攻击(DDoS:Distributed Denial of Service)
DDoS攻击通过大量合法的请求占用大量网络资源,以达到瘫痪网络的目的. 指借助于客户/服务器技术,将多个计算机联合起来作为攻击平台,对一个或多个目标发动DDoS攻击,从而成倍地提高拒绝服务攻击的威力. ...