问一个Q,并得到一个csv文件? [英] asking a Q and get it out of a csv file?

查看:89
本文介绍了问一个Q,并得到一个csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Q = question

Q = question

我想从csv文件访问信息,例如,如果该文件包含:

I want to access information from a csv file, for example if the file included:

NAME|DATE OF BIRTH|PHONE NUMBER|

 xxx|yyyyyyyyyyyyy| zzzzzzzzzzz|

 xxx|yyyyyyyyyyyyy| zzzzzzzzzzz|

 xxx|yyyyyyyyyyyyy| zzzzzzzzzzz|

我如何提出一个问题,例如:

How would I ask a question, example:

(伪码)

您要查找的人的姓名是什么?

(pseudo code)
what is the name of the person you are looking for? :

并且为了让python得到信息并显示它?

And for python to get the information and display it?

推荐答案

p>没有为你编写所有代码...

Without writing all your code for you...

将你的问题分解成你需要实现的不同组件:

Break your problem down into the different components you need to implement:


  • 阅读 a < a href =http://docs.python.org/3/library/csv.html =nofollow>。CSV 文件

  • 整理数据检索(一个或多个 dicts ,可以用来查找记录的每个字段)可能是最简单的解决方案)

  • 获取用户 input (提出问题)

  • 检索所请求的数据

  • 向用户显示请求的数据

  • Read a .CSV file
  • Organize the data for retrieval (one or more dicts, keyed by each field you might want to use to look up records, is probably the simplest solution)
  • Get user input ("ask a question")
  • Retrieve the requested data
  • Display the requested data to the user

研究)如何单独实现这些,然后你可以编写你的程序来做到这一点。如果您对某个特定作品有特定问题,请使用您撰写的程式码回到SO,并说明您遇到的问题。

Figure out (i.e. research) how to implement each of these individually, and then you can write your program to do that. If you then have a specific problem with a specific piece, come back to SO with the code you've written and explain the trouble you're having.

这篇关于问一个Q,并得到一个csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆