Python : 3.10.9 (原打算用3.11.1版本,后来发现飞桨最高支持到3.10版本)
paddlepaddle: 2.4.1
paddlenlp: 2.4.1 (最新版是2.5.0,由于一直报错,降级到2.4.1)
seqeval: 1.2.2
准备学习一下paddlenlp 于是按照官方的说明进行安装,使用官方提供的代码进行测试,测试代码:
信息抽取
from pprint import pprint
from paddlenlp import Taskflow
schema = ['时间', '选手', '赛事名称'] # Define the schema for entity extraction
ie = Taskflow('information_extraction', schema=schema)
pprint(ie("2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌!"))
如果正常执行,应该会输出下面信息:
[{'时间': [{'end': 6,
'probability': 0.9857378532924486,
'start': 0,
'text': '2月8日上午'}],
'赛事名称': [{'end': 23,
'probability': 0.8503089953268272,
'start': 6,
'text': '北京冬奥会自由式滑雪女子大跳台决赛'}],
'选手': [{'end': 31,
'probability': 0.8981548639781138,
'start': 28,
'text': '谷爱凌'}]}]
但是事情并灭有很顺利,直接报错了,错误提示信息如下:
E:\pytodo\venv\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
File "e:\pytodo\test01.py", line 4, in <module>
from paddlenlp import Taskflow
File "E:\pytodo\venv\lib\site-packages\paddlenlp\__init__.py", line 30, in <module>
File "E:\pytodo\venv\lib\site-packages\paddlenlp\metrics\__init__.py", line 16, in <module>
from .chunk import ChunkEvaluator
File "E:\pytodo\venv\lib\site-packages\paddlenlp\metrics\chunk.py", line 20, in <module>
from seqeval.metrics.sequence_labeling import get_entities
ModuleNotFoundError: No module named 'seqeval'
根据提示,重新手动安装“seqeval”库,pip install seqeval ,安装默认最新版本的1.2.2 ,安装过程很顺利,也没有错误,但是再次运行,还是包同样错误。
查了一下原因,根据github的提示,应该是 seqeval 要安装1.2.1 版本的,于是手动进行安装。
然而,pip install seqeval ==1.2.1 进行安装,有报错了……
venv) PS E:\pytodo> pip install seqeval==1.2.1
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/, https://pypi.tuna.tsinghua.edu.cn/simple/, https://pypi.douban.com/simple/, https://mirrors.ustc.edu.cn/pypi/
Collecting seqeval==1.2.1
Using cached https://pypi.doubanio.com/packages/c4/47/f85f522f1f2532ca650474088e4024a9f52d524379bff058eaadf53cb663/seqeval-1.2.1.tar.gz (43 kB)
Preparing metadata (setup.py) ... done
Collecting numpy==1.19.2
Using cached https://pypi.doubanio.com/packages/bf/e8/15aea783ea72e2d4e51e3ec365e8dc4a1a32c9e5eb3a6d695b0d58e67cdd/numpy-1.19.2.zip (7.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [257 lines of output]
Running from numpy source directory.
setup.py:470: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
run_build = parse_setuppy_commands()
Processing numpy/random\_bounded_integers.pxd.in
Processing numpy/random\bit_generator.pyx
Processing numpy/random\mtrand.pyx
Processing numpy/random\_bounded_integers.pyx.in
Processing numpy/random\_common.pyx
Processing numpy/random\_generator.pyx
Processing numpy/random\_mt19937.pyx
Processing numpy/random\_pcg64.pyx
Processing numpy/random\_philox.pyx
Processing numpy/random\_sfc64.pyx
Cythonizing sources
blas_opt_info:
blas_mkl_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
libraries mkl_rt not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
blis_info:
libraries blis not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
openblas_info:
libraries openblas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
customize G95FCompiler
Could not locate executable g95
customize IntelEM64VisualFCompiler
customize IntelEM64TFCompiler
Could not locate executable efort
Could not locate executable efc
customize PGroupFlangCompiler
Could not locate executable flang
don't know how to compile Fortran code on platform 'nt'
NOT AVAILABLE
atlas_3_10_blas_threads_info:
Setting PTATLAS=ATLAS
libraries tatlas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
atlas_3_10_blas_info:
libraries satlas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
accelerate_info:
NOT AVAILABLE
C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\system_info.py:1914: UserWarning:
Optimized (vendor) Blas libraries are not found.
Falls back to netlib Blas library which has worse performance.
A better performance should be easily gained by switching
Blas library.
if self._calc_info(blas):
blas_info:
libraries blas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\system_info.py:1914: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
if self._calc_info(blas):
blas_src_info:
NOT AVAILABLE
C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\system_info.py:1914: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
if self._calc_info(blas):
NOT AVAILABLE
non-existing path in 'numpy\\distutils': 'site.cfg'
lapack_opt_info:
lapack_mkl_info:
libraries mkl_rt not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
openblas_lapack_info:
libraries openblas not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
openblas_clapack_info:
libraries openblas,lapack not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
flame_info:
libraries flame not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in E:\pytodo\venv\lib
libraries tatlas,tatlas not found in E:\pytodo\venv\lib
libraries lapack_atlas not found in C:\
libraries tatlas,tatlas not found in C:\
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
NOT AVAILABLE
atlas_3_10_info:
libraries lapack_atlas not found in E:\pytodo\venv\lib
libraries satlas,satlas not found in E:\pytodo\venv\lib
libraries lapack_atlas not found in C:\
libraries satlas,satlas not found in C:\
<class 'numpy.distutils.system_info.atlas_3_10_info'>
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in E:\pytodo\venv\lib
libraries ptf77blas,ptcblas,atlas not found in E:\pytodo\venv\lib
libraries lapack_atlas not found in C:\
libraries ptf77blas,ptcblas,atlas not found in C:\
<class 'numpy.distutils.system_info.atlas_threads_info'>
NOT AVAILABLE
atlas_info:
libraries lapack_atlas not found in E:\pytodo\venv\lib
libraries f77blas,cblas,atlas not found in E:\pytodo\venv\lib
libraries lapack_atlas not found in C:\
libraries f77blas,cblas,atlas not found in C:\
<class 'numpy.distutils.system_info.atlas_info'>
NOT AVAILABLE
lapack_info:
libraries lapack not found in ['E:\\pytodo\\venv\\lib', 'C:\\']
NOT AVAILABLE
C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\system_info.py:1748: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
return getattr(self, '_calc_info_{}'.format(name))()
lapack_src_info:
NOT AVAILABLE
C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\system_info.py:1748: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
return getattr(self, '_calc_info_{}'.format(name))()
NOT AVAILABLE
numpy_linalg_lapack_lite:
FOUND:
language = c
define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]
C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\dist.py:275: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
running dist_info
running build_src
build_src
building py_modules sources
creating build
creating build\src.win-amd64-3.10
creating build\src.win-amd64-3.10\numpy
creating build\src.win-amd64-3.10\numpy\distutils
building library "npymath" sources
Traceback (most recent call last):
File "E:\pytodo\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>
main()
File "E:\pytodo\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "E:\pytodo\venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 152, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\build_meta.py", line 157, in prepare_metadata_for_build_wheel
self.run_setup()
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\build_meta.py", line 248, in run_setup
super(_BuildMetaLegacyBackend,
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 499, in <module>
setup_package()
File "setup.py", line 491, in setup_package
setup(**metadata)
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\core.py", line 169, in setup
return old_setup(**new_attr)
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\command\dist_info.py", line 31, in run
egg_info.run()
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\egg_info.py", line 24, in run
self.run_command("build_src")
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\build_src.py", line 144, in run
self.build_sources()
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\build_src.py", line 155, in build_sources
self.build_library_sources(*libname_info)
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\build_src.py", line 288, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\build_src.py", line 378, in generate_sources
source = func(extension, build_dir)
File "numpy\core\setup.py", line 650, in get_mathlib_info
st = config_cmd.try_link('int main(void) { return 0;}')
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 243, in try_link
self._link(body, headers, include_dirs,
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\config.py", line 161, in _link
return self._wrap_method(old_config._link, lang,
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\config.py", line 95, in _wrap_method
ret = mth(*((self,)+args))
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 137, in _link
(src, obj) = self._compile(body, headers, include_dirs, lang)
ls\command\config.py", line 104, in _compile
src, obj = self._wrap_method(old_config._compile, lang,
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\command\config.py", line 95, in _wrap_method
ret = mth(*((self,)+args))
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\command\config.py", line 132, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "C:\Users\admin\AppData\Local\Temp\pip-build-env-0uexikep\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 401, in compile
self.spawn(args)
return super().spawn(cmd, env=env)
File "C:\Users\admin\AppData\Local\Temp\pip-install-_drm9w48\numpy_e4ace71c56d54bf7af156925b951ce98\numpy\distutils\ccompiler.py", line 90, in <lambda>
m = lambda self, *args, **kw: func(self, *args, **kw)
TypeError: CCompiler_spawn() got an unexpected keyword argument 'env'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
经过一番查看,应该是1.2.1版本不支持python 3.10 版本,这下蒙了……难道要自己去编译源码?
于是去下载了1.2.1版本的源码回来,正准备编译一下呢,但是反过来一想,源码都有了,还编译啥!直接上源码!
于是把源码文件直接粘贴到site-packages文件夹里,然后再次执行代码……
E:\pytodo\venv\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
E:\pytodo\venv\lib\site-packages\jieba\_compat.py:4: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
import imp
[2023-01-13 13:59:14,601] [ INFO] - Downloading model_state.pdparams from https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/uie_base_v1.1/model_state.pdparams
100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 450M/450M [10:15<00:00, 766kB/s]
[2023-01-13 14:09:32,557] [ INFO] - Downloading model_config.json from https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/uie_base/model_config.json
100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 377/377 [00:00<00:00, 45.0kB/s]
[2023-01-13 14:09:32,769] [ INFO] - Downloading vocab.txt from https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/uie_base/vocab.txt
100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 182k/182k [00:00<00:00, 543kB/s]
[2023-01-13 14:09:33,294] [ INFO] - Downloading special_tokens_map.json from https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/uie_base/special_tokens_map.json
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 112/112 [00:00<00:00, 112kB/s]
[2023-01-13 14:09:33,446] [ INFO] - Downloading tokenizer_config.json from https://bj.bcebos.com/paddlenlp/taskflow/information_extraction/uie_base/tokenizer_config.json
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 172/172 [00:00<00:00, 172kB/s]
[2023-01-13 14:09:33,632] [ INFO] - loading configuration file C:\Users\fwrx\.paddlenlp\taskflow\information_extraction\uie-base\model_config.json
[2023-01-13 14:09:33,634] [ INFO] - Model config ErnieConfig {
"architectures": [
"UIE"
],
"attention_probs_dropout_prob": 0.1,
"enable_recompute": false,
"fuse": false,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"hidden_size": 768,
"initializer_range": 0.02,
"intermediate_size": 3072,
"layer_norm_eps": 1e-12,
"max_position_embeddings": 2048,
"model_type": "ernie",
"num_attention_heads": 12,
"num_hidden_layers": 12,
"pad_token_id": 0,
"paddlenlp_version": null,
"pool_act": "tanh",
"task_id": 0,
"task_type_vocab_size": 3,
"type_vocab_size": 4,
"use_task_id": true,
"vocab_size": 40000
}
[2023-01-13 14:09:33,643] [ INFO] - Configuration saved in C:\Users\fwrx\.paddlenlp\taskflow\information_extraction\uie-base\config.json[2023-01-13 14:09:56,586] [ INFO] - All model checkpoint weights were used when initializing UIE.
[2023-01-13 14:09:56,587] [ INFO] - All the weights of UIE were initialized from the model checkpoint at C:\Users\fwrx\.paddlenlp\taskflow\information_extraction\uie-base.
If your task is similar to the task the model of the checkpoint was trained on, you can already use UIE for predictions without further training.
[2023-01-13 14:09:56,590] [ INFO] - Converting to the inference model cost a little time.
[2023-01-13 14:10:20,229] [ INFO] - The inference model save in the path:C:\Users\fwrx\.paddlenlp\taskflow\information_extraction\uie-base\static\inference
[2023-01-13 14:10:25,183] [ INFO] - We are using <class 'paddlenlp.transformers.ernie.tokenizer.ErnieTokenizer'> to load 'C:\Users\fwrx\.paddlenlp\taskflow\information_extraction\uie-base'.
[{'时间': [{'end': 6,
'probability': 0.9857378532473966,
'start': 0,
'text': '2月8日上午'}],
'赛事名称': [{'end': 23,
'probability': 0.8503081103003893,
'start': 6,
'text': '北京冬奥会自由式滑雪女子大跳台决赛'}],
'选手': [{'end': 31,
'probability': 0.8981535684051067,
'start': 28,
'text': '谷爱凌'}]}]
看样子是首次运行代码,有下载了一些模型库等数据。
经过一会的运行之后,结果出来了!
Python 3.10版本可用的源码在这里:Python3.10版本可用的seqeval-1.2.1版本源码-Python文档类资源-CSDN文库
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Pythonconditionalassignmentoperator对于这样一个简单的问题表示歉意,但是谷歌搜索||=并不是很有帮助;)Python中是否有与Ruby和Perl中的||=语句等效的语句?例如:foo="hey"foo||="what"#assignfooifit'sundefined#fooisstill"hey"bar||="yeah"#baris"yeah"另外,类似这样的东西的通用术语是什么?条件分配是我的第一个猜测,但Wikipediapage跟我想的不太一样。
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
华为OD机试题本篇题目:明明的随机数题目输入描述输出描述:示例1输入输出说明代码编写思路最近更新的博客华为od2023|什么是华为od,od薪资待遇,od机试题清单华为OD机试真题大全,用Python解华为机试题|机试宝典【华为OD机试】全流程解析+经验分享,题型分享,防作弊指南华为o
我想解析一个已经存在的.mid文件,改变它的乐器,例如从“acousticgrandpiano”到“violin”,然后将它保存回去或作为另一个.mid文件。根据我在文档中看到的内容,该乐器通过program_change或patch_change指令进行了更改,但我找不到任何在已经存在的MIDI文件中执行此操作的库.他们似乎都只支持从头开始创建的MIDI文件。 最佳答案 MIDIpackage会为您完成此操作,但具体方法取决于midi文件的原始内容。一个MIDI文件由一个或多个音轨组成,每个音轨是十六个channel中任何一个上的
本文主要介绍在使用Selenium进行自动化测试或者任务时,对于使用了iframe的页面,如何定位iframe中的元素文章目录场景描述解决方案具体代码场景描述当我们在使用Selenium进行自动化测试的时候,可能会遇到一些界面或者窗体是使用HTML的iframe标签进行承载的。对于iframe中的标签,如果直接查找是无法找到的,会抛出没有找到元素的异常。比如近在咫尺的例子就是,CSDN的登录窗体就是使用的iframe,大家可以尝试通过F12开发者模式查看到的tag_name,class_name,id或者xpath来定位中的页面元素,会抛出NoSuchElementException异常。解决
2022/8/4更新支持加入水印水印必须包含透明图像,并且水印图像大小要等于原图像的大小pythonconvert_image_to_video.py-f30-mwatermark.pngim_dirout.mkv2022/6/21更新让命令行参数更加易用新的命令行使用方法pythonconvert_image_to_video.py-f30im_dirout.mkvFFMPEG命令行转换一组JPG图像到视频时,是将这组图像视为MJPG流。我需要转换一组PNG图像到视频,FFMPEG就不认了。pyav内置了ffmpeg库,不需要系统带有ffmpeg工具因此我使用ffmpeg的python包装p
ValidPalindromeGivenastring,determineifitisapalindrome,consideringonlyalphanumericcharactersandignoringcases. [#125]Example:"Aman,aplan,acanal:Panama"isapalindrome."raceacar"isnotapalindrome.Haveyouconsiderthatthestringmightbeempty?Thisisagoodquestiontoaskduringaninterview.Forthepurposeofthisproblem
是否可以在PyYAML或Ruby的Psych引擎中禁用创建anchor和引用(并有效地显式列出冗余数据)?也许我在网上搜索时遗漏了一些东西,但在Psych中似乎没有太多可用的选项,而且我也无法确定PyYAML是否允许这样做.基本原理是我必须序列化一些数据并将其以可读的形式传递给一个不是真正的技术同事进行手动验证。有些数据是多余的,但我需要以最明确的方式列出它们以提高可读性(anchor和引用是提高效率的好概念,但不是人类可读性)。Ruby和Python是我选择的工具,但如果有其他一些相当简单的方法来“展开”YAML文档,它可能就可以了。 最佳答案
我很好奇.NET将如何影响Python和Ruby应用程序。用IronPython/IronRuby编写的应用程序是否会非常特定于.NET环境,以至于它们实际上将变得特定于平台?如果他们不使用任何.NET功能,那么IronPython/IronRuby相对于非.NET同类产品的优势是什么? 最佳答案 我不能说任何关于IronRuby的东西,但是大多数Python实现(如IronPython、Jython和PyPy)都试图尽可能忠实于CPython实现。不过,IronPython正在迅速成为这方面的佼佼者之一,并且在PlanetPyth