我不得不搜索一点才能找到这个,我希望下面的内容能对其他人有所帮助。

Python 2.7import numpy as npfrom StringIO import StringIOdata = "1, abc , 2\n 3, xxx, 4"print type(data)"""

"""print '\n', np.genfromtxt(StringIO(data), delimiter=",", dtype="|S3", autostrip=True)"""

[['1' 'abc' '2']

['3' 'xxx' '4']]

"""print '\n', type(data)"""

"""print '\n', np.genfromtxt(StringIO(data), delimiter=",", autostrip=True)"""

[[  1.  nan   2.]

[  3.  nan   4.]]

"""

Python 3.5:import numpy as npfrom io import StringIOimport io

data = "1, abc , 2\n 3, xxx, 4"#print(data)"""

1, abc , 2

3, xxx, 4

"""#print(type(data))"""

"""#np.genfromtxt(StringIO(data), delimiter=",", autostrip=True)# TypeError: Can't convert 'bytes' object to str

implicitlyprint('\n')print(np.genfromtxt(io.BytesIO(data.encode()), delimiter=",", dtype="|S3", autostrip=True))"""

[[b'1' b'abc' b'2']

[b'3' b'xxx' b'4']]

"""print('\n')print(np.genfromtxt(io.BytesIO(data.encode()), delimiter=",", autostrip=True))"""

[[  1.  nan   2.]

[  3.  nan   4.]]

"""

撇开:

其中x={1,2,3,.}中的任何一种:

“s1和s2字符串是数据类型描述符;第一个表示数组包含长度为1的字符串,第二个字符串的长度为2.”

python stringio_Python 3中的StringIO相关推荐

  1. python stringio_python 在内存中读写:StringIO / BytesIO

    操作字符串,使用StringIO#!/usr/bin/python # -*- coding: utf-8 -*- from io import StringIO f = StringIO() f.w ...

  2. python io模块_python中的StringIO模块

    原博文 2015-10-23 15:21 − # python中的StringIO模块 标签:python StringIO --- > 此模块主要用于在内存缓冲区中读写数据.模块是用类编写的, ...

  3. python 在内存中读写:StringIO / BytesIO

    操作字符串,使用StringIO #!/usr/bin/python # -*- coding: utf-8 -*-from io import StringIOf = StringIO() f.wr ...

  4. Python中的StringIO与cStringIO简析

    <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255) ...

  5. python stringio_python StringIO类

    python的stringIO类用来处理字符串,由于其操作类似文件操作,可以视为内存中的文件. 1.创建stringIO 2.常用操作: write,writelines.getvalue.seek. ...

  6. python中IO编程中关于StringIO的读写问题

    阅读前请看一下:我是一个热衷于记录的人,每次写博客会反复研读,尽量不断提升博客质量.文章设置为仅粉丝可见,是因为写博客确实花了不少精力.希望互相进步谢谢!! 文章目录 阅读前请看一下:我是一个热衷于记 ...

  7. python在内存中生成Zip文件!

    python在内存中生成Zip文件! - 天真的好蓝啊 - 博客园 python在内存中生成Zip文件! import zipfile import StringIO class MemoryZipF ...

  8. Python标准库中的io

    Python标准库中io模块中有两个比较重要的组成部分:StringIO.BytesIO 1.StringIO StringIO 的作用是在内存中读写字符串,其示例代码如下: from io impo ...

  9. Python3中的StringIO

    本文翻译自:StringIO in Python3 I am using Python 3.2.1 and I can't import the StringIO module. 我正在使用Pytho ...

最新文章

  1. html5摒弃的标记,5 HTML5的列表标记
  2. 利用Landsat8 进行利用土地分类
  3. matlab GUI gca gco gcf
  4. 在Visual C++ 中使用内联汇编
  5. Linux下安装Oracle遇到的错误
  6. android自定义控件是一个 内部类 如何在xml中引用,android 自定义view属性
  7. sql插入临时表数据的方法
  8. python中import sys_python import sys出错怎么办
  9. 十、request.getSession( )、reqeust.getSession(false)和 request.getSession(true)
  10. 通过jquer连接数据库里面的数据、LINQ简介
  11. Android 系统(229)---OTA
  12. python3用什么软件_apt-get 如何给python3装软件?
  13. 今天和大家分享几个可以接私活的网站(偏软件)(转载21ic)
  14. 实战 | 如何使用微搭低代码实现公差申请应用
  15. 整合营销中广告投放策略,为何需要选择公关广告?
  16. 复旦和同济计算机学硕,考研择校:复旦、同济、上财哪个更有前途?看网友怎么说!...
  17. 甲骨文裁员犯的病,任正非早在10年前就开出了药方
  18. CSS练习中|无序列表中,<li>的小黑点如何替换为图片(菜鸡趣味学习,细节到每一步)
  19. 在线图片裁剪,关于使用cropperjs踩过的坑
  20. jsf的verbatim标签

热门文章

  1. 你可以是个孩子,但是我对你的期望…
  2. IPv6 tcp socket HBH扩展报头设置
  3. SwiftUI 精品项目之照片编辑器图像裁剪工具(教程含源码)
  4. 【网络英语每日英文】第61期
  5. Vmware tools安装(已解决VMware和win鼠标不能自由切换问题)
  6. ArchLinux系统安装(BIOS)
  7. 软件测试面试指导之自我介绍 (干货)
  8. solidworks中装配体如何旋转一个零件
  9. pdf 阅读,保存上次阅读位置
  10. execstartpost_systemd