我一直在尝试在 Windows 10 中使用 pyinstaller 构建 .exe 文件。它起作用了,但 exe 文件的大小约为 212 MB,即使使用 venv(如此处所示)。我想可能是因为我正在使用 anaconda 的 python!
然后我安装了一个单独的 Python 版本,所以不使用 anaconda!但它不起作用(仍然是大文件)。
然后我卸载了anaconda进行测试。Pyinstaller 仍在尝试访问“C:\Program Files\anaconda3\python.exe”中的Python (此错误:“C:\Program Files\anaconda3\python.exe”中没有 Python)。但是我已经删除了 anaconda 的所有路径。可能它一直试图访问 anaconda,这就是为什么我没有成功构建一个小尺寸的 .exe 文件。
如何清楚地指示 pyinstaller 和 python 的路径?
所以我试图让美元符号直接出现在“成本”列下数字的左侧。我无法解决这个问题,任何帮助表示赞赏。
# Question 5
print("\nQuestion 5.")
# Get amount of each type of ticket to be purchased
adultTickets = input("\nHow many adult tickets you want to order: ")
adultCost = int(adultTickets) * 50.5
childTickets = input("How many children (>=10 years old) tickets: ")
childCost = int(childTickets) * 10.5
youngChildTickets = input("How many children (<10 years old) tickets: ")
# Display ticket info
print ("\n{0:<17} {1:>17} {2:>12}".format("Type", "Number of tickets",
"Cost"))
print ("{0:<17} {1:>17}${2:>12.2f}".format("Adult", adultTickets, adultCost))
print ("{0:<17} {1:>17}${2:>12.2f}".format("Children (>=10)", childTickets, …Run Code Online (Sandbox Code Playgroud) 我刚刚使用 Python 3.8 为 Windows x64 安装了最新版本的 Anaconda,并想添加该tensorflow模块。
根据这个网站,tensorflow 2.2.0应该是可用的。
但是,我的 Anaconda 仅建议tensorflow 2.1.0安装它而无法安装,因为它与 Python 3.8 不兼容。
我该如何安装tensorflow 2.2.0?
我正在编写一个程序,程序的一部分是我想使用递归函数创建一个包含字符串中所有子字符串的列表。
但是,当我返回列表时,我什么也没得到。变量 substringList 具有 None 值。
如何返回列表而不丢失其中的所有数据?
def main(string):
substringList = []
substringList = substring(string, substringList)
def substring(string, substringList):#Recursive function to create all the
length = len(string) #substrings**strong text**
if length == 0:
return substringList
else:
substringList.append(string)
substring(string[1::], substringList)
string = "bananas"
main(string)
Run Code Online (Sandbox Code Playgroud) 我是熊猫的新手,我想过滤熊猫中的数据框,其中包含列表中的 top5 值。使用该代码从列表中获取 5 个值的最佳方法是什么?
我的代码:
cheese_top5 = cheese[cheese.year >= 2016]
Run Code Online (Sandbox Code Playgroud) 遇到不受支持的类型错误,刚刚更新了熊猫并确保它运行的是 1.0.3 版。有任何想法吗?谢谢!
我正在学习 python 并尝试学习如何使用 map() 函数。
有想法将字符串中的字母更改为字母表中的等效 +1,例如:abc -> bcd
写了以下代码:
m = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def func(s):
return m[m.index(s) + 1]
l = "abc"
print(set(map(func, l)))
Run Code Online (Sandbox Code Playgroud)
但是每次执行都会返回不同的字母顺序
我通过使用得到了预期的答案:
l2 = [func(i) for i in s]
print(l2)
Run Code Online (Sandbox Code Playgroud)
但我想了解 map() 函数及其工作原理。试图阅读文档,但我不太明白。很抱歉我的英语不好和我缺乏 python 经验:/
当我通过 Conda 安装 tensorflow-gpu 时;它给了我以下输出:
conda install tensorflow-gpu
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/psychotechnopath/anaconda3/envs/DeepLearning3.6
added / updated specs:
- tensorflow-gpu
The following packages will be downloaded:
package | build
---------------------------|-----------------
_tflow_select-2.1.0 | gpu 2 KB
cudatoolkit-10.1.243 | h6bb024c_0 347.4 MB
cudnn-7.6.5 | cuda10.1_0 179.9 MB
cupti-10.1.168 | 0 1.4 MB
tensorflow-2.1.0 |gpu_py36h2e5cdaa_0 4 KB
tensorflow-base-2.1.0 |gpu_py36h6c5654b_0 155.9 MB
tensorflow-gpu-2.1.0 | h0d30ee6_0 3 KB
------------------------------------------------------------
Total: 684.7 MB
The following NEW packages …Run Code Online (Sandbox Code Playgroud) 我想在不使用 for 循环的情况下在两个字符串之间应用按位 OR。例如;
first_string = "0101"
second_string = "1010"
result = "1111"
Run Code Online (Sandbox Code Playgroud)
有没有办法在不分解单词的情况下计算单词?所以我的意思是最快的方式
我正在尝试使用 Requests 和 BeautifulSoup在https://www.twitch.tv/directory/game/Dota%202上获取流的标题。我知道我的搜索条件是正确的,但我的程序没有找到我需要的元素。
这是一个屏幕截图,显示了浏览器中源代码的相关部分:
作为文本的 HTML 源代码:
<div class="tw-media-card-meta__title">
<div class="tw-c-text-alt">
<a class="tw-full-width tw-interactive tw-link tw-link--button tw-link--hover-underline-none tw-link--inherit" data-a-target="preview-card-title-link" href="/weplayesport_en">
<div class="tw-align-items-start tw-flex">
<h3 class="tw-ellipsis tw-font-size-5" title="NAVI vs HellRaisers | BO5 | ODPixel & S4 | WeSave! Charity Play">NAVI vs HellRaisers | BO5 | ODPixel & S4 | WeSave! Charity Play</h3>
</div>
</a>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import requests
from bs4 import BeautifulSoup
req = requests.get("https://www.twitch.tv/directory/game/Dota%202")
soup = BeautifulSoup(req.content, "lxml")
title_elems = soup.find_all("h3", attrs={"title": True})
print(title_elems)
Run Code Online (Sandbox Code Playgroud)
当我运行它时,title_elems …
python ×10
conda ×3
anaconda ×2
pandas ×2
tensorflow ×2
cuda ×1
cudnn ×1
pyinstaller ×1
web-scraping ×1