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
最满意答案
如果您真的想写入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.
-
Flume错误:连接被拒绝(Flume Error: connection refused)[2023-10-18]
您的配置是从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 ... -
无法与MongoDB连接(Can't connect with MongoDB)[2022-09-07]
当你在一个对象上调用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 ...
-
为什么Mongodb不能连接?(Why cannot Mongodb connect?)[2023-04-17]
从第一个终端 ./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(Can't connect to mongodb)[2022-04-22]
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 ... -
Mongodb:连接失败(Mongodb:Failed to connect)[2024-04-30]
短暂的休息后,我可以找到解决方案。 该问题的根源是系统意外关闭。所以我在命令提示符下运行以下代码: 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 ...