小编Jer*_*nes的帖子

如何更改由 Python-pptx 创建的表格中文本的字体大小

我正在创建一个脚本来显示产品性能图表,并创建一个表格来显示其部件号、应用程序列表和当前应用程序的数量。

但是,默认字体大小太大,无法将所有这些信息放入幻灯片中,需要缩小。

如何在 Python-pptx 中减小表格中文本的字体大小?

这就是我所拥有的,但我不断收到错误消息“AttributeError: '_Cell' 对象没有属性 'paragraph'”

table = shapes.add_table(rows, cols, left + left_offset, top + Inches(.25), width, height - Inches(.25)).table
#column width
for i in range(3):
    table.columns[i].width = col_width[i]           
    for i in range(len(a_slide)):
        #color table
        if i % 2 == 0:
            for j in range(3):
                fill = table.cell(i, j).fill
                fill.background()
        else:
            for j in range(3):
                fill = table.cell(i, j).fill
                fill.solid()
                fill.fore_color.rgb = RGBColor(240, 128, 128)
        #populate table
        table.cell(i, 0).text = str(item["name"])
        try:
            table.cell(i, 1).text = ", ".join(item["app"]) …
Run Code Online (Sandbox Code Playgroud)

python-3.x python-pptx

7
推荐指数
1
解决办法
3337
查看次数

Python Unittest抛出未捕获的TypeError:__ init __()占用1个位置参数,但给出了2个

我正在尝试首次使用unittest创建我的第一个自动化测试套件.

但是,当我尝试执行我的测试套件时,unittest会抛出以下异常:

Traceback (most recent call last):

File "testing_pos_line.py", line 31, in <module>
    unittest.main()
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\main.py", line 93, in __init__
    self.parseArgs(argv)
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\main.py", line 140, in parseArgs
    self.createTests()
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\main.py", line 144, in createTests
    self.test = self.testLoader.loadTestsFromModule(self.module)
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\loader.py", line 123, in loadTestsFromModule
    tests.append(self.loadTestsFromTestCase(obj))
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\loader.py", line 92, in loadTestsFromTestCase
    loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\suite.py", line 24, in __init__
    self.addTests(tests)
  File "C:\Users\barnej78\AppData\Local\Continuum\Anaconda3\lib\unittest\suite.py", line 57, in addTests
    for test in tests:
TypeError: __init__() takes 1 positional argument but 2 were …
Run Code Online (Sandbox Code Playgroud)

python python-unittest

2
推荐指数
1
解决办法
2601
查看次数

scikit-image Gabor 过滤器错误:`过滤器权重数组的形状不正确`

输入是灰度图像,转换为 130x130 numpy 矩阵。我总是收到错误:

Traceback (most recent call last):
  File "test_final.py", line 87, in <module>
    a._populate_gabor()

  File "C:\Users\Bears\Dropbox\School\Data Science\final.py", line 172, in _populate_gabor
    self.gabor_imgs[i] = self._matrix_2_1d(self._gabor_this(self.grey_imgs[i]),kernels[0])

  File "C:\Users\Bears\Dropbox\School\Data Science\final.py", line 179, in _gabor_this
    filtered = ndi.convolve(image, kernel, mode='reflect')

  File "C:\Users\Bears\Anaconda3\lib\site-packages\scipy\ndimage\filters.py", line 696, in convolve
    origin, True)

  File "C:\Users\Bears\Anaconda3\lib\site-packages\scipy\ndimage\filters.py", line 530, in _correlate_or_convolve
    raise RuntimeError('filter weights array has incorrect shape.')
RuntimeError: filter weights array has incorrect shape.
Run Code Online (Sandbox Code Playgroud)

我的代码如下

def _populate_gabor(self):
    kernels = []
    for theta in range(self.gabor_range[0],self.gabor_range[1]):
        theta = theta / …
Run Code Online (Sandbox Code Playgroud)

python arrays numpy scikit-image

1
推荐指数
1
解决办法
1万
查看次数