笨办法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 ...
随机推荐
- Spark大型电商项目实战-及其改良之番外(1)-将spark前端页面效果高效拷贝至博客
Spark大型电商项目实战-及其改良这个系列的时间轴展示图一直在变....1-3篇是用图直接表示时间轴,用一段简陋的html代码表示时间表.第4篇开始才是用比较完整的前端效果,能移动.缩放时间轴,鼠标 ...
- 网易cetus数据库中间件安装-读写分离版本
安装前提:1.数据库主从关系要做好:2.授权用户登录要做好:3.mysql最大连接数设置好,不然会报连接错误:4.版本最好是5.6以上. 1.安装依赖 yum install cmake gcc gl ...
- vue3.0使用axios报错问题记录
vue-cli3.0使用axios的时候出现错误,记录一下 报错信息: Uncaught TypeError: Cannot set property $axios of #<Vue> w ...
- 爬虫中xpath的特殊用法
Xpath之starts-with(@属性名称,属性字符串相同部分) 以相同的字符开头的用法 在做爬虫时解析html的源码时候可能会遇见以下这种标签, <div id="test-1& ...
- SPOJ DQUERY D-query(主席树 区间不同数个数)
题意:问你区间有几个不同的数 思路:主席树nb.我们知道主席树每一个root都存着一棵权值线段树,现在我们在每个root中存位置,也就是01表示这个位置存不存在.然后我们用一个fa[a[i]]表示a[ ...
- C# 将对应的xml文档赋值给指定模型(对象)
public static IList<T> XmlToEntityList<T>(string xml) where T : new() { ...
- 新的尝试!ComponentOne WinForm 和 .NET Core 3.0
在微软 Build 2018 开发者大会上,.NET 团队公布了 .NET Core 的下一个主要版本 .NET Core 3.0 的规划蓝图:.NET Core 3将开始支持Windows桌面应用程 ...
- springboot后台控制重定向
第一种方式: 1. 使用 @Controller 注解而不是 @RestController 2.方法上不要加 @ResponseBody 然后直接返回你要去的页面 比如 return & ...
- postman(九):postman接口测试脚本集成到jenkins
本篇的目的是实现使用jenkins远程执行postman接口测试脚本 准备工作:一台linux服务器(可以用虚拟机搭建一个),linux服务器上安装好node.js.newman,部署好jenkins ...
- [数据算法]D1.BloomFilter
BloomFilter是一种高效的去重算法,算法的要义是散列对比. 1.原理 当一个元素加入集合时,判断这个元素是否 2.举例 例如我要对URL去重(这个在爬虫上可以用): URL1 -> 3. ...