笨办法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 ...
随机推荐
- Vue 组件&组件之间的通信 之 使用slot分发内容
slot详细介绍网址:https://cn.vuejs.org/v2/api/#slot 有时候我们需要在自定义组件内书写一些内容,例如: <com-a> <h1>title& ...
- ajax的三次封装简单概况
原生ajax: readyState 准备状态 status 页面状态 ...
- C# Winform ComBox三种赋值方式
https://www.cnblogs.com/ingstyle/p/4815303.html 第一种方法: DataTable dt = new DataTable(); dt.Columns.Ad ...
- 论文笔记:ProxylessNAS: Direct Neural Architecture Search on Target Task and Hardware
ProxylessNAS: Direct Neural Architecture Search on Target Task and Hardware 2019-03-19 16:13:18 Pape ...
- [java] 软工实践WordCount-Plus
整体思路 模块化 对于任何一个小模块,例如:输入.输出.计算都独立开来,降低耦合. 插件化 对于任何一个模块均作成插件,可拔插,可更换,而不会导致其他的插件出现故障. 事件驱动 使用观察者模式,用事件 ...
- Complex类的设计与改进
Complex类 源码 #include <cmath> #include <iomanip> #include <iostream> #include <s ...
- 网站性能测试工具 webbench 的安装和使用
1.webbench的下载和安装 wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz sudo tar xvf we ...
- grep 从文件内容中查找
grep -rin [查找目标] [查找范围] 例子:在当前目录下的文件内查找test字符串 grep -rin test ./
- Js原生封装选项卡组件
class MyTab extends HTMLElement{ //创建一个类名MyTab constructor(){ //构造函数 super(); //指向父类构造函数,必须要有的 const ...
- 20165303魏煜第一周kali安装
1.根据网址下载kali 这是kali的下载地址https://www.kali.org 找到download选择Kali Linux 64 bit VMware VM,点击后面蓝色部分开始下载选择6 ...