泡菜:导入错误:没有模块命名为经理

时间:2019-02-02 00:14:47

标签: python pickle

我正在使用import java.awt.EventQueue; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.DocumentFilter; public class JavaApplication100 { public static void main(String[] args) { new JavaApplication100(); } public JavaApplication100() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class TestPane extends JPanel { public TestPane() { setLayout(new GridBagLayout()); setBorder(new EmptyBorder(10, 10, 10, 10)); JTextField field = new JTextField(10); ((AbstractDocument)field.getDocument()).setDocumentFilter(new PropercaseDocumentFilter()); add(field); } } public class PropercaseDocumentFilter extends DocumentFilter { @Override public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { text = modify(fb, offset, text, attrs); super.replace(fb, offset, length, text, attrs); } protected String modify(FilterBypass fb, int offset, String text, AttributeSet attrs) throws BadLocationException { if (text.length() > 0) { Document doc = fb.getDocument(); StringBuilder sb = new StringBuilder(text); if (doc.getLength() == 0) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } else if (offset > 0 && offset < doc.getLength()) { if (doc.getText(offset - 1, 1).equals(" ")) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } } else if (doc.getText(doc.getLength() - 1, 1).equals(" ")) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } text = sb.toString(); } return text; } } } 和Python 2.7.14像这样对由cPickle(LabelEncoder, NumPy array, NumPy array)组成的元组进行腌制:

le_arr1_arr2.pkl

我使用pickle.dump((le, arr1, arr2), open("le_arr1_arr2.pkl", "wb")) 1.71版在ML Engine实例(Linux计算机)上进行此操作。

然后将其复制到笔记本电脑(mac)中,然后尝试:

cPickle

我再次使用le, arr1, arr2 = pickle.load(open("le_arr1_arr2.pkl", "rb")) 1.71版,我得到了:

cPickle

知道这里发生了什么吗?我很困惑...

谢谢!

0 个答案:

没有答案