首页 \ 问答 \ Python while循环条件(Python while-loop conditions)

Python while循环条件(Python while-loop conditions)

我只是在while循环中有一个关于Python循环条件的快速问题。 我希望以(得分/最高分数)的形式从用户那里获取输入,例如(13/15)。 我希望把它放入一个while循环中,它会不断要求用户以这种形式输入输入,直到他们做对了。

到目前为止,我有这个

num1 = 0
while num1 !='?/?':
    num1 = raw_input("Please enter your score in the form socre/max(eg. 30/50)")

我知道如何使用单个数字检查条件是否为真,例如:while x> 18,或者条件是字符串,例如:while x!='Start'。 我不确定使用什么作为15/20条件的参数,其中这两个数字将以15/20的精确形式输入。 任何帮助将不胜感激。

谢谢


I just have a quick question about Python loop conditions in the while loop. I am looking to take input from the user in the form of (score/max score) eg (13/15). I am looking to put this into a while loop that will continuously ask the user to enter the input in this form until they do it right.

So far, I have this

num1 = 0
while num1 !='?/?':
    num1 = raw_input("Please enter your score in the form socre/max(eg. 30/50)")

I know how to check if a condition is true with a single number, such as: while x > 18, or if the condition is a string, such as: while x != 'Start'. I am not sure what to use as the parameters for the condition of 15/20, where these two numbers will be input in this exact form 15/20. Any help would be greatly appreciated.

Thank you


原文:https://stackoverflow.com/questions/49715746
更新时间:2023-08-01 14:08

最满意答案

如果您真的想写入MongoDB或从MongoDB读取,我无法理解您的问题。

我想你想写一下MongoDB,你已经有了一个很好的起点来扩展或开发你自己的定制接收器

在您希望从MongoDB中读取的情况下,您需要按照Flume开发人员指南中提到的示例从头开始实施解决方案(您可以重用上面提供的GitHub链接中的一些代码部分)。


I could not understand from you question if you actually want to write to MongoDB or read from MongoDB.

I case you would like to write to MongoDB, you already have a good starting point to extend or develop you own custom sink.

In a case you would like to read from MongoDB, you will need to implement a solution from scratch, following the examples mentioned on the Flume Developer Guide (you can reuse some of the parts of the code from GitHub link provided above).

相关问答

更多
  • 只需使用MongoClient 。 您可以从PECL存储库安装此扩展。 Just use MongoClient. You can install this extension from PECL repository.
  • 您的配置是从exec源读取事件并使用Avro on localhost:4141发送它们。 但是,错误日志表明您没有在localhost:4141上运行Avro源。 你需要一个Avro源(可能是另一个代理)监听该端口。 Your configuration is to read events from the exec source and send them on using Avro on localhost:4141. However, the error log indicates that you ...
  • 当你在一个对象上调用new时,就像你在main中调用new一样,这意味着Spring已经不在了。 对象的创建和满足其依赖性取决于您。 您不应该调用new来创建该对象。 最好实例化Spring Bean工厂并要求它为您提供所需的实例以及所有依赖关系。 这是新Spring用户常见的误解。 他们调用new并且无法理解为什么他们的Spring依赖关系没有连线。 When you call new on an object, like you do in your main, that means Spring is ...
  • 如果您真的想写入MongoDB或从MongoDB读取,我无法理解您的问题。 我想你想写一下MongoDB,你已经有了一个很好的起点来扩展或开发你自己的定制接收器 。 在您希望从MongoDB中读取的情况下,您需要按照Flume开发人员指南中提到的示例从头开始实施解决方案(您可以重用上面提供的GitHub链接中的一些代码部分)。 I could not understand from you question if you actually want to write to MongoDB or read f ...
  • 从第一个终端 ./mongod --port 27017 从另一个 ./mongo --port 27017 假设在两个终端中你都在mongo可执行目录中。 根据需要更改端口。 另外ctrl + C不是问题,我总是用那个来关闭。 From first terminal ./mongod --port 27017 From another one ./mongo --port 27017 Assuming in both terminals you are in mongo executable di ...
  • 关于Flume代理体系结构,它由负责接收或轮询事件的源以极简主义形式组成,并将事件转换为放置在通道中的 Flume事件。 然后,接收器接收这些事件以便将数据保存在某处,或将数据发送给另一个代理。 所有这些组件(源,通道,接收器,即代理)都在同一台机器上运行。 相反,可以分发不同的代理。 话虽如此,您的场景似乎需要基于JMS源 ,通道(通常是内存通道 )和HDFS接收器的单个代理。 如文档中所述,JMS源仅针对ActiveMQ进行了测试,但是对任何其他队列系统都进行了测试。 该文档还提供了一个示例: a1.s ...
  • MongoDB没有运行,我猜测你的错误是这样的: 使用Homebrew安装mongodb时遇到困难 创建path /data/db ,然后尝试再次启动MongoDB。 (运行mongod ) MongoDB is not running, and I have a wild guess that your mistake is this one: Trouble installing mongodb using Homebrew Create the path /data/db and then try t ...
  • 短暂的休息后,我可以找到解决方案。 该问题的根源是系统意外关闭。所以我在命令提示符下运行以下代码: sudo rm /var/lib/mongodb/mongod.lock mongod --repair sudo service mongodb start 然后在上面的代码运行后,它的工作正常:) After a short break, I can find out the solution. The origin of that issue is the unexpected shutdown of ...
  • 我收到了Claudera的回复,他们说由于windows没有内置tail程序,所以需要使用Cygwin来实现这种功能。 我们不想安装cygwin,所以我正在寻找替代解决方案。 根据Claudera的说法,另一种方法是使用C# Thrift绑定 ,它将在同一个Windows机器上发送带有Thrift源的Flume代理数据。 我不确定你如何为Flume代理指定一个Thrift源,但据说它可以完成。 I got a response from Claudera and they state that since ...
  • MongoDB只是数据库层,而不是像Hadoop生态系统那样的完整解决方案。 我实际上使用Kafka和Storm在MongoDB中存储数据,以防需要处理和存储大量的传入数据。 MongoDB is just the database layer, not the complete solution like the Hadoop ecosystem. I actually use Kafka along with Storm to store data in MongoDB in cases where t ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)