_csv.reader'对象不可订阅(_csv.reader' object is not subscriptable)
我在python中的csv模块有问题。
这是我编写的解析我的csv的代码
def parse(data): data_delim = data.split("\n") data_list = csv.reader(data_delim) return data_list
我遇到的问题如下:
print(data_list[Enum.check_name(skill)][1])
引发此错误
_csv.reader' object is not subscriptable
我在下面有一个贫民窟解决方案,但我宁愿使用类似于上面代码的东西,有人有解决方案吗?
i = 0 for a in data_list: if i == Enum.check_name(skill): print(a[1]) i += 1
I have a problem with the csv module in python.
This is the code I've written to parse my csv
def parse(data): data_delim = data.split("\n") data_list = csv.reader(data_delim) return data_list
The problem I am encountering is the following:
print(data_list[Enum.check_name(skill)][1])
Throws this error
_csv.reader' object is not subscriptable
I have a ghetto solution for this below, but I'd rather use something similar to the code above, does anyone have a solution to this?
i = 0 for a in data_list: if i == Enum.check_name(skill): print(a[1]) i += 1
原文:https://stackoverflow.com/questions/32038776
更新时间:2023-08-11 18:08
最满意答案
不是
readLines
而是readline
。n <- as.integer(readline(prompt = "Please enter sample size > "))
稍微有点执行:
read_value <- function(prompt_text = "", prompt_suffix = getOption("prompt"), coerce_to = "character") { prompt <- paste(prompt_text, prompt_suffix) as(readline(prompt), coerce_to) } read_value("Please enter sample size", coerce_to = "integer")
Not
readLines
butreadline
.n <- as.integer(readline(prompt = "Please enter sample size > "))
A slightly fancier implementation:
read_value <- function(prompt_text = "", prompt_suffix = getOption("prompt"), coerce_to = "character") { prompt <- paste(prompt_text, prompt_suffix) as(readline(prompt), coerce_to) } read_value("Please enter sample size", coerce_to = "integer")
相关问答
更多-
R控制台是用我的母语,如何将R设置为英文?(The R console is in my native language, how can I set R to English?)[2022-12-11]
在一个全新的安装中,在R_HOME\etc文件(默认情况下,在R_HOME\etc )中添加language = en将使R的语言英文在R控制台以及RStudio中。 这可以被工作目录和RStudio的各个项目中的代码所覆盖。 On a fresh install, adding language = en to the Rconsole file (which exists by default under R_HOME\etc) will make R's language English in the ... -
如果您的意思是从控制台视图获取用户输入,则可以使用Scanner类或Console类。 代码示例: Scanner reader = new Scanner(System.in); String userInput = reader.next(); 要么 Console console = System.console(); String userInput = console.readLine("Please input:"); If you mean getting user input from ...
-
处理中的用户交互(User interaction in Processing)[2022-01-01]
检查几何图书馆。 它有一种方法来检查鼠标是否在任何SVG形状内。 我记不起我的头顶,但它的作用就像你塑造一样: myShape = RG.loadShape("shape.svg"); 和一点: RPoint p = new RPoint(mouseX, mouseY); 并且布尔函数contains()会告诉你该点是否在形状内部: myShape.contains(p); Check out the geomerative library. It has a way to check whether ... -
模拟用户交互(Simulate User Interaction)[2022-10-16]
我自己没有用过它,但AutoIt似乎就是你要找的东西。 I haven't used it myself, but AutoIt seems to be what your looking for. -
如果你想要做的就是最初加载文件,你不必依赖Shiny函数来做到这一点。 你可以依靠R函数。 像这样设置您的应用: ui <- shinyUI( fileInput("inFile", label="Choose a file", multiple=F) ) server <- shinyServer(function(input, output, session) { values <- reactiveValues() dat <- reactive({ if (is.null(i ...
-
一个快速的谷歌搜索指向我svDialogs包。 尝试 library(svDialogs) okCancelBox("Hello") 它返回TRUE / FALSE,你可以使用它 A quick Google search pointed me to the svDialogs package. Try library(svDialogs) okCancelBox("Hello") it returns TRUE / FALSE and you can use that
-
(控制台)R中的用户交互?((console) user interaction in R?)[2023-04-09]
不是readLines而是readline 。 n <- as.integer(readline(prompt = "Please enter sample size > ")) 稍微有点执行: read_value <- function(prompt_text = "", prompt_suffix = getOption("prompt"), coerce_to = "character") { prompt <- paste(prompt_text, prompt_suffix) as(r ... -
阅读Hadley Wickham撰写的R套餐 。 你想要什么 是 应该是包的默认行为:您具有导出和未导出的功能。 除非您明确地将函数声明为已导出,否则它对外部是不可见的,并且只能由包内的其他函数使用。 所以你不需要为辅助函数做任何事情。 但是,您需要将main函数标记为已导出。 Read R packages by Hadley Wickham. What you want is should be the default behaviour for packages: you have exported ...
-
R interaction.plot(R interaction.plot)[2023-08-10]
看起来没有错误。 每组的平均值为2.0,这是情节显示的。 > df$drug <- as.numeric(levels(df$drug))[df$drug] > library(plyr) > ddply(df, .(biofeedback, diet), summarise, val = mean(drug)) biofeedback diet val 1 absent absent 2 2 absent present 2 3 present absen ... -
即使没有Rcpp, std::cin也不适合交互式输入。 要将R控制台与Rcpp一起使用,您需要使用R函数(特别是readline )而不是C ++函数。 幸运的是,您可以将R对象拉入C ++代码: Environment base = Environment("package:base"); Function readline = base["readline"]; Function as_numeric = base["as.numeric"]; 然后你可以使用它们: int drink = as
相关文章
更多- Guava学习笔记:复写的Object常用方法
- Object Oriented Programming
- Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案
- (五) solr 索引数据导入:csv格式
- 不显示删除回复显示所有回复显示星级回复显示得分回复 请问java Object的hashcode()方法是怎么实现的啊,内部的算法是什么啊
- 关于对象复制时出现内容不一致的问题
- Storm【设计细节】 -Fields对象
- javascript 对象转换成json格式数据(使用JSON.stringify)
- 微信消息回复,订阅号或服务号C#
- Python内建函数(G)
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。