我已经使用 pyfpdf 模块生成了 PDF 文件,但我注意到每行中的文本未正确对齐。
我需要在单元格中进行文本换行才能自动调整。我尝试使用下面的代码生成固定大小的 PDF 文件,但它无法将文本混合在行中,您可以检查评论中的屏幕截图来查看问题。
我需要动态调整表列大小。请帮忙。
代码 :
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=8)
item_data = [['Item Name', 'Last clock', 'lastvalue'], ['cl Loaded Class Count', '0', '0'], ['cl Total Loaded Class Count', '0', '0'], ['cl Unloaded Class Count', '0', '0'], ['comp Name of the current JIT compiler', '0', ''], ['comp Accumulated time spent in compilation', '0', '0'], ['gc ConcurrentMarkSweep number of collections per second', '0', '0'], ['gc ConcurrentMarkSweep accumulated time spent in collection', '0', '0'], ['gc Copy …Run Code Online (Sandbox Code Playgroud) (我确实发现了很多类似的问题,但到目前为止这些问题都不适合我......)
============更新了错误信息、图像、命令行============
我试图#include <Python.h>在visual studio中(这几乎是所有代码,主要功能几乎是空的),但它不断提醒我cannot open source file "Python.h",如果我运行该程序,它会引发错误:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
. 我在 project Property Pages> 中添加了 include 和 library 目录VC++ Directories,不起作用,尝试将路径添加到C/C++> Additional Include Directories,不起作用,我尝试将其更改为发布模式,但仍然无法正常工作...
================更新2.0================
我添加%(AdditionalIncludeDirectories);到C/C++>Additional Include Directories但似乎不起作用。
然后我做了一些非常愚蠢的事情:我将标头和.dll复制到标头包含文件夹......现在它不会提醒我再也找不到Python.h了,我可以编码:
Py_Initialize();
PyRun_SimpleString("print('Hello Python!')");
Py_Finalize();
Run Code Online (Sandbox Code Playgroud)
但它不会编译...我收到一条新的错误消息:
'"C:\Amarth\Programing\CPlusPlusLearning\Release\CPlusPlusLearning.exe"' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
在输出中,它是:
1>------ Build …Run Code Online (Sandbox Code Playgroud) 我用这种形式写了很多数据(从文件中读取):
(31265+0j)
(-5613.54281374+404.957401125j)
(1371.65134844+2671.06617046j)
...
Run Code Online (Sandbox Code Playgroud)
然而我想提取数字部分,比如[31265, 0]或[-5613.54281374 , 404.957401125],我在python中编码的方式我认为它会起作用:
re.findall(r'.*([\+|\-]?\d+.?\d+)([\+|\-]?\d+.?\d+).*', tempStr)
Run Code Online (Sandbox Code Playgroud)
但它不起作用,它给了我这个:
[]
[('26', '5+0')]
[('11', '25')]
...
Run Code Online (Sandbox Code Playgroud)
它出什么问题了?它是关于懒惰模式的吗?我该如何解决?
========================更新========================我,这个问题已经解决了,但我仍然想知道正则表达式部分有什么问题,有人愿意帮我指出正则表达式模式有什么问题吗?
我写了一个类,其中有一个函数接受几个输入*args,但是运行结果证明它只接受来自第二个的参数,就好像self取第一个,这里是一个简化的代码:
class incorrect():
def itera(self, *args):
for i in args:
print(i)
a = incorrect
a.itera(12, 23, 34)
Run Code Online (Sandbox Code Playgroud)
输出12丢失了:
23
34
Run Code Online (Sandbox Code Playgroud)
问题是什么?我该如何解决这个问题?
我遵循了一个教程,并尝试在按时使程序退出q,但这是行不通的,无论我按哪个键都可以退出,这是代码:
twi = cv2.imread('large.png')
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.imshow('image', twi)
key = cv2.waitKey(0)
if key == ord('q'):
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
而且我尝试添加&0xFF:
key = cv2.waitKey(0)&0xFF
Run Code Online (Sandbox Code Playgroud)
仍然无法正常工作,这有什么问题?我可以解决吗?
=============更新============
我还添加print(key)了一点,当按下时q,变量key是113,并且ord('q')是113,都不明白为什么它不起作用...
============已解决=============
(似乎我忘记了if工作原理...)