python - 将 python 对象转换为字符串,编辑它并转换回原始类型的对象

标签 python matplotlib translate-animation

晚上好,我有这种类型的 python 对象。这里有什么方法可以将它转换为字符串、编辑并转换回来吗?

 <class 'matplotlib.transforms.CompositeGenericTransform'>

当我通过 print(variable) 打印它时,它看起来像这样:

CompositeGenericTransform(CompositeGenericTransform(CompositeGenericTransform(CompositeGenericTransform(CompositeGenericTransform(TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform())), CompositeGenericTransform(BboxTransformFrom(TransformedBbox(Bbox('array([[ -19.5      ,  -10.7983871],\n       [ 221.5      ,  140.7983871]])'), TransformWrapper(BlendedAffine2D(IdentityTransform(),IdentityTransform())))), BboxTransformTo(TransformedBbox(Bbox('array([[ 0.125,  0.25 ],\n       [ 0.9  ,  0.9  ]])'), BboxTransformTo(TransformedBbox(Bbox('array([[ 0.,  0.],\n       [ 8.,  6.]])'), Affine2D(array([[ 80.,   0.,   0.],
       [  0.,  80.,   0.],
       [  0.,   0.,   1.]])))))))), Affine2D(array([[ 0.99968918, -0.02493069,  6.98903935],
       [ 0.02493069,  0.99968918, -8.59039721],
       [ 0.        ,  0.        ,  1.        ]]))), Affine2D(array([[ 0.99968918, -0.02493069,  6.93499095],
       [ 0.02493069,  0.99968918, -7.14592338],
       [ 0.        ,  0.        ,  1.        ]]))), Affine2D(array([[ 0.99968918, -0.02493069,  6.88226449],
       [ 0.02493069,  0.99968918, -6.30113809],
       [ 0.        ,  0.        ,  1.        ]]))), Affine2D(array([[ 0.99968918, -0.02493069,  6.96735103],
       [ 0.02493069,  0.99968918, -7.27368166],
       [ 0.        ,  0.        ,  1.        ]])))

最佳答案

你可以用 Pickle 做到这一点,它是 Python 的对象序列化库。

关于python - 将 python 对象转换为字符串,编辑它并转换回原始类型的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21322151/

相关文章:

python - web2py 中 SQLFORM 小部件输入的自定义 CSS 类

python - 创建一个绘图,将其保存到文件,然后加载该文件并在 matplotlib 中的新绘图旁边绘图

matplotlib - IPython 绘图内联不显示

android - 当 android :targetSdkVersion ="17" not specified in manifest. xml for Android 4.1.2 (Samsung Galaxy s2 gt-i9100) 时, View (按钮)不可见

javascript - CSS 转换后光标在 IE11 中的错误位置

python - 删除以特定字符开头的 token

python - 从 LineStringField 中提取坐标

单击gridview的项目时的android动画

python - Heroku 上的“导入错误 : No module named ' , flask ”

python - pyplot 双对数等高线图不起作用