笨办法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 ...
随机推荐
- POI中excle样式怎么写
POI中可能会用到一些需要设置EXCEL单元格格式的操作小结: 先获取工作薄对象: HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb ...
- java如何编写多线程
1.如何实现多线程 1.1实现Runnable接口,实现run()方法. public class Main4 implements Runnable { public static void mai ...
- vector某元素是否存在、查找指定元素 、去重
vector.map 判断某元素是否存在.查找指定元素 [C++]判断元素是否在vector中,对vector去重,两个vector求交集.并集 PS:注意重载
- 64位 windows2008 R2 上安装32位oracle 10g 的方法
首先,我们要解除oracle安装的windows版本检测1.编辑安装包内文件 database\stage\prereq\db\refhost.xml 在 <OPERATING_SYSTEM& ...
- P2495 [SDOI2011]消耗战
思路 虚树上DP 虚树相当于一颗包含了所有询问的关键点信息的树,包含的所有点只有询问点和它们的LCA,所以点数是\(2k\)级别的,这样的话复杂度就是\(O(\sum k)\),复杂度就对了 虚树重点 ...
- 论文笔记:AdaScale: Towards real-time video object detection using adaptive scalingAdaScale
AdaScale: Towards real-time video object detection using adaptive scaling 2019-02-18 16:14:17 Paper: ...
- 浅谈Cocos2d-js ListView滑动防止误触
Event背景 最近,接到一个需求,优化房间内设置界面: 表面问题:用户在按钮表面,滑动界面的时候,总会误触到界面上的按钮或者复选框 根本问题:由于ListView的事件具有传递性,导致双重事件触发, ...
- Linux之磁盘信息查看
一.磁盘情况查询 1.查看磁盘整体情况 命令:df 参数: -a:列出所有的文件系统,包括系统特有的/proc等文件系统 -k:以KB的容量显示各文件系统 -m:以MB的容量显示各文件系统 -h:以人 ...
- js中关于数组处理的一些小技巧
1 reduce方法同时实现map和filter 假设现在有一个数组,然后遍历它的每一项(map的功能)然后筛选出其中的一部分(filter的功能).如果使用map和filter的话,我们需要遍历这个 ...
- Disable access to Windows Update
Disable access to Windows Update If this policy setting is enabled, all Windows Update features are ...