使用多处理下载文件时出现以下错误。我正在下载维基百科页面浏览量,他们按小时计算,因此可能包含大量下载。
关于为什么会导致此错误以及如何解决它的任何建议?谢谢
MaybeEncodingError:发送结果错误:''。原因:'TypeError("cannot serialize '_io.BufferedReader' object",)'
import fnmatch
import requests
import urllib.request
from bs4 import BeautifulSoup
import multiprocessing as mp
def download_it(download_file):
global path_to_save_document
filename = download_file[download_file.rfind("/")+1:]
save_file_w_submission_path = path_to_save_document + filename
request = urllib.request.Request(download_file)
response = urllib.request.urlopen(request)
data_content = response.read()
with open(save_file_w_submission_path, 'wb') as wf:
wf.write(data_content)
print(save_file_w_submission_path)
pattern = r'*200801*'
url_to_download = r'https://dumps.wikimedia.org/other/pagecounts-raw/'
path_to_save_document = r'D:\Users\Jonathan\Desktop\Wikipedia\\'
def main():
global pattern
global url_to_download
r = requests.get(url_to_download)
data = r.text
soup = BeautifulSoup(data,features="lxml")
list_of_href_year = []
for i in …Run Code Online (Sandbox Code Playgroud) 我有一个运行 python 脚本的批处理文件,在 python 脚本中,我有一个正在运行的子进程函数。
我已经试过subprocess.check_output,subprocess.run,subprocess.Popen,所有的人都返回我使用批处理文件运行,只有当它为空字符串。
如果我手动或使用 IDE 运行它,我会得到正确的响应。下面是代码subprocess.run:
response = subprocess.run(fileCommand, shell=True, cwd=pSetTableauExeDirectory, capture_output=True)
self.writeInLog(' Command Response: \t' + str(response))
Run Code Online (Sandbox Code Playgroud)
响应在 stdout=b''
在批处理文件和任务计划程序中运行时:
命令响应:CompletedProcess(args='tableau refreshextract --config-file "Z:\XXX\tableau_config\SampleSuperStore.txt"', returncode=0, stdout=b'', stderr=b'')
手动或在 IDE 中运行时:
命令响应:CompletedProcess(args='tableau refreshextract --config-file "Z:\XXX\tableau_config\SampleSuperStore.txt"', returncode=0, stdout=b'数据源刷新完成。\r\n0 行已上传。\ r\n', stderr=b'')
运行python程序的批处理文件。参数被解析到python应用程序
SET config=SampleSuperStore.txt
CALL C:\XXX\AppData\Local\Continuum\anaconda3\Scripts\activate.bat
C:\XXX\AppData\Local\Continuum\anaconda3\python.exe Z:\XXX\pMainManual.py "%config%"
Run Code Online (Sandbox Code Playgroud)
这是为什么??
--完整的python代码---
try:
from pWrapper import wrapper
import sys
except Exception as e:
print(str(e))
class main:
def __init__(self):
self.tableauPath = 'C:\\Program …Run Code Online (Sandbox Code Playgroud) 当用户保存文件时,我想默认在文件对话框中放置一个值。任何人都可以建议它的语法?
saveFilePath = fileDialog.asksaveasfile(mode='w', title="Save the file", defaultextension=".txt")
Run Code Online (Sandbox Code Playgroud)
例如:打开文件对话框时应填写NewFile
我有一个要从中过滤数据的表。我尝试了以下查询
SELECT
SIS, COUNT(*)
FROM DL_SQ_DEV_INT.SMRY_DAILY_TRAILER_REPORT
GROUP BY 1;
Result:
BL,17386
EQ,3242
FIFO,5747
GR,15655
HOLD,13035
LT BL,20566
LT GR,14615
LT OR,14190
LT PU,13877
LT YE,13683
null,223376
OR,15727
PI,3563
PU,16105
RW,200
TA,6
tbd,25302
WH,1945
YE,14510
Run Code Online (Sandbox Code Playgroud)
现在,当我在其中添加 WHERE 子句时,它会过滤掉空值。查询是不等于 (<>)。如何避免这种情况并且结果中仍然存在空值?将 null 更改为空白或空格?
SELECT
SIS, COUNT(*)
FROM DL_SQ_DEV_INT.SMRY_DAILY_TRAILER_REPORT
WHERE UPPER(TRIM(SIS)) <> 'EQ'
GROUP BY 1;
Result:
BL,17386
FIFO,5747
GR,15655
HOLD,13035
LT BL,20566
LT GR,14615
LT OR,14190
LT PU,13877
LT YE,13683
OR,15727
PI,3563
PU,16105
RW,200
TA,6
tbd,25302
WH,1945
YE,14510
Run Code Online (Sandbox Code Playgroud) 我正在使用 pptx python 创建一个表
参考:https : //python-pptx.readthedocs.io/en/latest/dev/analysis/tbl-table.html
创建表格时,我获得了默认表格样式,我想更改它。有什么推荐吗?
x, y, cx, cy = Inches(4.5), Inches(1.5), Inches(4.0), Inches(0)
shape = slide.shapes.add_table(7, 5, x, y, cx, cy)
table = shape.table
Run Code Online (Sandbox Code Playgroud)
我在想,table.apply_style()但我无法弄清楚正确的语法
python ×3
python-3.x ×3
batch-file ×1
powerpoint ×1
python-pptx ×1
sql ×1
subprocess ×1
tableau-api ×1
teradata ×1
teradatasql ×1
tkinter ×1