'UnicodeEncodeError:'ascii'codec'尝试使用python将£sign写入excel表时出错

时间:2017-03-09 20:28:41

标签: python html excel beautifulsoup python-unicode

我在python中抓取一个£值,当我尝试将它写入excel表时,进程中断,我得到以下错误

UnicodeEncodeError:'ascii'编解码器无法对位置0中的字符u'\ xa3'进行编码:序数不在范围内(128)

£符号在cmd提示符下打印时没有任何错误。有人可以建议我如何将价值(£1,750)写入我的表格(有或没有£符号)。非常感谢...

Starting remote process.I/ActivityManager(  460): Start proc org.qtproject.example.tableview for activity org.qtproject.example.tableview/org.qtproject.qt5.android.bindings.QtActivity: pid=12235 uid=10057 gids={50057, 3003, 1028, 1015}
D/dalvikvm(12235): Not late-enabling CheckJNI (already on)
D/dalvikvm(12235): GC_CONCURRENT freed 331K, 13% free 2853K/3260K, paused 5ms+2ms, total 65ms
D/dalvikvm(12235): GC_CONCURRENT freed 309K, 12% free 2963K/3352K, paused 4ms+2ms, total 42ms
D/dalvikvm(12235): GC_CONCURRENT freed 439K, 16% free 2918K/3436K, paused 3ms+3ms, total 42ms
D/dalvikvm(12235): GC_CONCURRENT freed 389K, 15% free 2932K/3436K, paused 4ms+2ms, total 42ms
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libgnustl_shared.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libgnustl_shared.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libgnustl_shared.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5Core.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5Core.so 0xb2d49770
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5Network.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5Network.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libQt5Network.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5Qml.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5Qml.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libQt5Qml.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5Gui.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5Gui.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libQt5Gui.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5Quick.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5Quick.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libQt5Quick.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5Widgets.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5Widgets.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libQt5Widgets.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5QuickParticles.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/lib/libQt5QuickParticles.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/lib/libQt5QuickParticles.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/qt-reserved-files/plugins/platforms/android/libqtforandroid.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/qt-reserved-files/plugins/platforms/android/libqtforandroid.so 0xb2d49770
I/Qt      (12235): qt start
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/qt-reserved-files/plugins/bearer/libqandroidbearer.so 0xb2d49770
D/dalvikvm(12235): Added shared lib /data/data/org.qtproject.example.tableview/qt-reserved-files/plugins/bearer/libqandroidbearer.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/data/org.qtproject.example.tableview/qt-reserved-files/plugins/bearer/libqandroidbearer.so 0xb2d49770, skipping init
D/dalvikvm(12235): Trying to load lib /data/data/org.qtproject.example.tableview/lib/libQt5QuickParticles.so 0xb2d49770
D/dalvikvm(12235): Shared lib '/data/data/org.qtproject.example.tableview/lib/libQt5QuickParticles.so' already loaded in same CL 0xb2d49770
W/System.err(12235): java.lang.ClassNotFoundException: android.graphics.drawable.RippleDrawable
W/System.err(12235):    at java.lang.Class.classForName(Native Method)
W/System.err(12235):    at java.lang.Class.forName(Class.java:251)
W/System.err(12235):    at java.lang.Class.forName(Class.java:216)
W/System.err(12235):    at org.qtproject.qt5.android.ExtractStyle.getClass(ExtractStyle.java:395)
W/System.err(12235):    at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:98)
W/System.err(12235):    at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:520)
W/System.err(12235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(12235):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtLoader.loadApplication(QtLoader.java:237)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:647)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:181)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:269)
W/System.err(12235):    at android.app.Activity.performCreate(Activity.java:5231)
W/System.err(12235):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err(12235):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
W/System.err(12235):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
W/System.err(12235):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err(12235):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
W/System.err(12235):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12235):    at android.os.Looper.loop(Looper.java:136)
W/System.err(12235):    at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err(12235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(12235):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(12235):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err(12235):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err(12235):    at dalvik.system.NativeStart.main(Native Method)
W/System.err(12235): Caused by: java.lang.NoClassDefFoundError: android/graphics/drawable/RippleDrawable
W/System.err(12235):    ... 26 more
W/System.err(12235): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.graphics.drawable.RippleDrawable" on path: DexPathList[[zip file "/data/app/org.qtproject.example.tableview-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.qtproject.example.tableview-1, /system/lib]]
W/System.err(12235):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err(12235):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
W/System.err(12235):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
W/System.err(12235):    ... 26 more
W/System.err(12235): java.lang.ClassNotFoundException: android.graphics.drawable.AnimatedStateListDrawable
W/System.err(12235):    at java.lang.Class.classForName(Native Method)
W/System.err(12235):    at java.lang.Class.forName(Class.java:251)
W/System.err(12235):    at java.lang.Class.forName(Class.java:216)
W/System.err(12235):    at org.qtproject.qt5.android.ExtractStyle.getClass(ExtractStyle.java:395)
W/System.err(12235):    at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:99)
W/System.err(12235):    at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:520)
W/System.err(12235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(12235):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtLoader.loadApplication(QtLoader.java:237)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:647)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:181)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:269)
W/System.err(12235):    at android.app.Activity.performCreate(Activity.java:5231)
W/System.err(12235):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err(12235):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
W/System.err(12235):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
W/System.err(12235):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err(12235):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
D/dalvikvm(12235): GC_CONCURRENT freed 363K, 14% free 2969K/3436K, paused 3ms+4ms, total 66ms
W/System.err(12235):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12235):    at android.os.Looper.loop(Looper.java:136)
W/System.err(12235):    at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err(12235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(12235):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(12235):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err(12235):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err(12235):    at dalvik.system.NativeStart.main(Native Method)
W/System.err(12235): Caused by: java.lang.NoClassDefFoundError: android/graphics/drawable/AnimatedStateListDrawable
W/System.err(12235):    ... 26 more
W/System.err(12235): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.graphics.drawable.AnimatedStateListDrawable" on path: DexPathList[[zip file "/data/app/org.qtproject.example.tableview-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.qtproject.example.tableview-1, /system/lib]]
W/System.err(12235):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err(12235):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
W/System.err(12235):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
W/System.err(12235):    ... 26 more
W/System.err(12235): java.lang.ClassNotFoundException: android.graphics.drawable.VectorDrawable
W/System.err(12235):    at java.lang.Class.classForName(Native Method)
W/System.err(12235):    at java.lang.Class.forName(Class.java:251)
W/System.err(12235):    at java.lang.Class.forName(Class.java:216)
W/System.err(12235):    at org.qtproject.qt5.android.ExtractStyle.getClass(ExtractStyle.java:395)
W/System.err(12235):    at org.qtproject.qt5.android.ExtractStyle.<init>(ExtractStyle.java:100)
W/System.err(12235):    at org.qtproject.qt5.android.QtActivityDelegate.loadApplication(QtActivityDelegate.java:520)
W/System.err(12235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(12235):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtLoader.loadApplication(QtLoader.java:237)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtLoader.startApp(QtLoader.java:647)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtActivityLoader.onCreate(QtActivityLoader.java:181)
W/System.err(12235):    at org.qtproject.qt5.android.bindings.QtActivity.onCreate(QtActivity.java:269)
W/System.err(12235):    at android.app.Activity.performCreate(Activity.java:5231)
W/System.err(12235):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
W/System.err(12235):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
W/System.err(12235):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
W/System.err(12235):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
W/System.err(12235):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
W/System.err(12235):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(12235):    at android.os.Looper.loop(Looper.java:136)
W/System.err(12235):    at android.app.ActivityThread.main(ActivityThread.java:5017)
W/System.err(12235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(12235):    at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(12235):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
W/System.err(12235):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
W/System.err(12235):    at dalvik.system.NativeStart.main(Native Method)
W/System.err(12235): Caused by: java.lang.NoClassDefFoundError: android/graphics/drawable/VectorDrawable
W/System.err(12235):    ... 26 more
W/System.err(12235): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.graphics.drawable.VectorDrawable" on path: DexPathList[[zip file "/data/app/org.qtproject.example.tableview-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.qtproject.example.tableview-1, /system/lib]]
W/System.err(12235):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err(12235):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
W/System.err(12235):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
W/System.err(12235):    ... 26 more
W/ResourceType(12235): Skipping entry 0x1080526 in package table 0 because it is not complex!
D/dalvikvm(12235): GC_CONCURRENT freed 265K, 12% free 3107K/3524K, paused 13ms+3ms, total 42ms
D/dalvikvm(12235): GC_CONCURRENT freed 339K, 14% free 3178K/3656K, paused 13ms+2ms, total 46ms
D/dalvikvm(12235): GC_FOR_ALLOC freed 50K, 15% free 3217K/3744K, paused 19ms, total 21ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.297MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed 5K, 14% free 3297K/3832K, paused 23ms, total 23ms
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3297K/3832K, paused 22ms, total 22ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.375MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3382K/3920K, paused 21ms, total 21ms
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3383K/3920K, paused 20ms, total 21ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.459MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3468K/4008K, paused 22ms, total 22ms
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3469K/4008K, paused 20ms, total 21ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.543MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3554K/4096K, paused 21ms, total 22ms
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 14% free 3555K/4096K, paused 21ms, total 21ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.626MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed 0K, 13% free 3640K/4184K, paused 22ms, total 22ms
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 13% free 3640K/4184K, paused 20ms, total 21ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.710MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 13% free 3725K/4272K, paused 22ms, total 22ms
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 13% free 3726K/4272K, paused 20ms, total 21ms
I/dalvikvm-heap(12235): Grow heap (frag case) to 3.794MB for 87280-byte allocation
D/dalvikvm(12235): GC_FOR_ALLOC freed <1K, 13% free 3811K/4360K, paused 20ms, total 21ms
D/dalvikvm(12235): GC_FOR_ALLOC freed 217K, 12% free 3878K/4360K, paused 18ms, total 21ms
D/dalvikvm(12235): GC_CONCURRENT freed 278K, 10% free 4003K/4412K, paused 3ms+4ms, total 44ms
D/dalvikvm(12235): GC_CONCURRENT freed 309K, 10% free 4144K/4564K, paused 3ms+3ms, total 54ms
D/dalvikvm(12235): GC_CONCURRENT freed 220K, 7% free 4332K/4636K, paused 16ms+12ms, total 56ms
D/dalvikvm(12235): GC_CONCURRENT freed 341K, 9% free 4427K/4848K, paused 4ms+3ms, total 44ms
D/dalvikvm(12235): GC_CONCURRENT freed 293K, 8% free 4574K/4944K, paused 3ms+3ms, total 46ms
D/dalvikvm(12235): GC_CONCURRENT freed 467K, 11% free 4618K/5164K, paused 4ms+3ms, total 46ms
D/dalvikvm(12235): GC_CONCURRENT freed 491K, 11% free 4678K/5252K, paused 3ms+2ms, total 46ms
D/dalvikvm(12235): GC_CONCURRENT freed 543K, 12% free 4730K/5356K, paused 14ms+12ms, total 57ms
D/dalvikvm(12235): GC_CONCURRENT freed 603K, 13% free 4770K/5424K, paused 4ms+4ms, total 59ms
D/dalvikvm(12235): GC_FOR_ALLOC freed 307K, 11% free 4922K/5500K, paused 22ms, total 23ms
D/dalvikvm(12235): GC_CONCURRENT freed 677K, 15% free 4890K/5708K, paused 13ms+13ms, total 57ms
D/dalvikvm(12235): GC_CONCURRENT freed 578K, 14% free 4964K/5708K, paused 12ms+3ms, total 57ms
D/dalvikvm(12235): Trying to load lib /data/app-lib/org.qtproject.example.tableview-1/libtableview.so 0xb2d49770
D/        (12235): (null):0 ((null)): QML debugging is enabled. Only use this in a safe environment.
D/dalvikvm(12235): Added shared lib /data/app-lib/org.qtproject.example.tableview-1/libtableview.so 0xb2d49770
D/dalvikvm(12235): No JNI_OnLoad found in /data/app-lib/org.qtproject.example.tableview-1/libtableview.so 0xb2d49770, skipping init
D/        (12235): HostConnection::get() New Host Connection established 0xb8fa82e8, tid 12235
D/OpenGLRenderer(12235): Enabling debug mode 0
D/        (12235): HostConnection::get() New Host Connection established 0xb93a73d8, tid 12252
D/        (12235): HostConnection::get() New Host Connection established 0xb8faa138, tid 12254
F/libc    (12235): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 12252 (ample.tableview)
I/DEBUG   (   50): pid: 12235, tid: 12252, name: ample.tableview  >>> org.qtproject.example.tableview <<<
D/Zygote  (   53): Process 12235 terminated by signal (11)
I/ActivityManager(  460): Process org.qtproject.example.tableview (pid 12235) has died.


"org.qtproject.example.tableview" died.

1 个答案:

答案 0 :(得分:1)

您需要明确地将unicode对象编码为字节。否则,您的系统将自动尝试使用ascii编解码器对其进行编码,该编解码器将使用非ascii字符进行编码。所以,这个:

Rateable_Value = Rateable_Value.encode('utf8')

之前

writer.writerow([Rateable_Value])

应该做的伎俩。