File class

路径分割符

  • File.seperator : "/" or "\"
  • File.pathSeperator: ":" or ";"

当前路径 pwd

File 类

  • 作用: 目录和文件
  • 用途:

    1. 本文件路径的基本操作

unittest

异常测试

1
2
3
4
5
6
class TestFormula(unittest.TestCase):
    def test_parse_forward_uncoupled_parse_error(self):
        f = 'H2O)'
        with self.assertRaises(ParseError) as e:
        Formula.parse_forward_with_bracket(f)
        self.assertTrue('With not coupled bracket' in str(e))

imageMagick

安装

1
sudo apt install imagemagick

报错

pdf security 报错

  • 引用

  • 方法

    Well, I added

    <policy domain="coder" rights="read | write" pattern="PDF" />

    just before </policymap> in /etc/ImageMagick-7/policy.xml and that makes it work again, but not sure about the security implications of that.

截图

  • -crop

    1
    
      convert  -density 200 ./one.pdf -quality 100 -colorspace gray -crop 500x500+500+500 "./one_300.jpg"

geometry 参数意义

  • 参考