eg1:

My csv data like this below,i wt count  list nums
2018上,"['C', 'B', 'B', 'B', 'D', 'A', 'B', 'C', 'A', 'D', 'B', 'D', 'A', 'A', 'A', 'C', 'D', 'B', 'C', 'B', 'A', 'C', 'A', 'D', 'A', 'D', 'B', 'D', 'B', 'C', 'B', 'A', 'D', 'B', 'C', 'B、C', 'B', 'B', 'B', 'D', 'B', 'C', 'C', 'B', 'B', 'D', 'A', 'D', 'D', 'C', 'B', 'B', 'A', 'B', 'C', 'B', 'B', 'B', 'A', 'A', 'A', 'C', 'A', 'B', 'A', 'A、A', 'B、C', 'C', 'D', 'B', 'C', 'C', 'A']" eg: df_data = np.array(pd.read_csv(answer_file, header=None))
new_data = []
for d in df_data:
y = d[]
ya = d[] # '[\\'C\\',\\'A\\']'
#(1)check one
y2 = np.array(ya) # ['C','A'] #this is what i not want
y2_test = y2.shape # 0-d
  
y2_test2 = y2.tolist() # dtype shows not list #the right methon
    #(2)check one
    ls = ya.strip('][').split(',')  # dtype show list 
#(3) right methon
import ast
ls = ast.iteral_eval(ya)
ls = [i.strip() for i in ls]

Python str list to list的更多相关文章

  1. #python str.format 方法被用于字符串的格式化输出。

    #python str.format 方法被用于字符串的格式化输出. #''.format() print('{0}+{1}={2}'.format(1,2,3)) #1+2=3 可见字符串中大括号内 ...

  2. Python str() 函数

    Python str() 函数  Python 内置函数 描述 str() 函数将对象转化为适于人阅读的形式. 语法 以下是 str() 方法的语法: class str(object='') 参数 ...

  3. Python str 与 bytes 类型(Python2/3 对 str 的处理)

    本文均在 Python 3 下测试通过,python 2.x 会略有不同. 1. str/bytes >> s = '123' >> type(s) str >> ...

  4. Python str & repr

    Python str & repr repr 更多是用来配合 eval 的 (<- 点击查看),str 更多是用来转换成字符串格式的 str() & repr() str() 和 ...

  5. Python str方法总结

    1.返回第一个字母大写 S.capitalize(...) S.capitalize() -> string 1 2 3 4 >>>a = 'shaw' >>> ...

  6. python str()与repr()

    相同点: 将任意值转为字符串 不同点: str()致力于生成一个对象的可读性好的字符串表示,它的返回结果通常无法用于eval()求值,但很适合用于print语句输出 repr()出来的值是给pytho ...

  7. Python str字符串常用到的函数

    # -*- coding: utf-8 -*- x='pythonnnnnnoooo' print type(x) # <type 'str'> 输出类型 print x.capitali ...

  8. python str.format()

    python中的字符串格式函数str.format(): #使用str.format()函数 #使用'{}'占位符 print('I\'m {},{}'.format('Hongten','Welco ...

  9. python str的一些方法

    在python有各种各样的string操作函数.在历史上string类在python中经历了一段轮回的历史.在最开始的时候,python有一个专门的string的module,要使用string的方法 ...

  10. python - str和repr方法:

    # python 内置__str__()和__repr__()方法: #显示自定制 # 示例1 # a = 123 # print(a.__str__()) # 示例2 class Test(): d ...

随机推荐

  1. 函数的嵌套+nonlocal和global关键字(重点)

    1.在函数中声明函数 在内部函数中使用变量的时候, 查找顺序: 先找自己 -> 上一层 -> 上一层..全局 -> 内置 # 函数的互相调用 # def func1(): # pri ...

  2. WPF 各种绑定写法以及用法

    一:{Binding ElementName=grid0, Path=Height} ElementName=grid0:查找到名为grid0的控件. , Path=Height:获取名为grid0的 ...

  3. ubuntu 手动修改分辨率为1920 X 1080 的两种方式

    方案一(临时性,重启会失效): 1.打开终端.输入:cvt 1920 1080 出现有modeline 的提示. 2.使用 xrandr 创建新的 mode,--newmode 后面跟刚刚 cvt 产 ...

  4. ROS学习手记 - 5 理解ROS中的基本概念_Services and Parameters

    上一节完成了对nodes, Topic的理解,再深入一步: Services and Parameters 我不理解为何 ROS wiki 要把service与parameter放在一起介绍, 很想分 ...

  5. 浏览器Hack演示

    <!doctype html> <html> <head> <title></title> <meta http-equiv=&quo ...

  6. leetcode1006

    func clumsy(N int) int { var ary []int ; n-- { ary = append(ary, n) } re := N % //4个数字一组 firstgroup ...

  7. leetcode1003

    class Solution: def isValid(self, S: str) -> bool: n = len(S) if n % 3 != 0: return False while n ...

  8. <基础> PHP 进阶之 类型转换

    引用官方的解释 PHP 在变量定义中不需要(或不支持)明确的类型定义:变量类型是根据使用该变量的上下文所决定的.也就是说,如果把一个 string 值赋给变量$var,$var 就成了一个 strin ...

  9. HashMap怎样解决碰撞问题

    碰撞:HashMap运用put方法存储多个元素时,计算得出相同的hashCode,在put时出现冲突. 处理:利用“拉链法”处理HashCode的碰撞问题:当我们将键值对传递给put方法时,他调用键对 ...

  10. 机器学习进阶-边缘检测-Canny边缘检测 1.cv2.Canny(进行Canny边缘检测)

    1. cv2.Canny(src, thresh1, thresh2) 进行canny边缘检测 参数说明: src表示输入的图片, thresh1表示最小阈值,thresh2表示最大阈值,用于进一步删 ...