Python 我如何知道用户输入的一句话的长度——不是整个输入——只是句子
我想做的是,我想做一个程序,用一种特殊的方式写用户的句子 我这样做是因为我完成了一门python速成课程,并且我正在坚持我的想法,这样我就可以进行机器学习,然后再学习其他语言。 谢谢Python 我如何知道用户输入的一句话的长度——不是整个输入——只是句子,python,Python,我想做的是,我想做一个程序,用一种特殊的方式写用户的句子 我这样做是因为我完成了一门python速成课程,并且我正在坚持我的想法,这样我就可以进行机器学习,然后再学习其他语言。 谢谢 同位素我想至少对我来说,这有点不清楚。你能给出一个你想要的例子吗?你需要澄清一个句子的定义。例如,它可能以特定字符结尾,例如[\!\.\?],然后对这些字符使用类似于re.split()的内容(为了安全起见,我对这些字符进行了转义,这可能是不必要的)。然后只需在第一句话中使用len(),即可获得字符数。谢谢,还有一
同位素我想至少对我来说,这有点不清楚。你能给出一个你想要的例子吗?你需要澄清一个句子的定义。例如,它可能以特定字符结尾,例如
[\!\.\?]
,然后对这些字符使用类似于re.split()
的内容(为了安全起见,我对这些字符进行了转义,这可能是不必要的)。然后只需在第一句话中使用len()
,即可获得字符数。谢谢,还有一条路要走!
import sys
# what does the program do
# 1- Recieve input from the user about what sentence does he want to write.
# 2- Recieve input from the user about WHAT sentences you want the system to write out using WHAT?.
# 3- Make a list about each sentence length.
# 4- Make if conditionals if any word from the alphabet exists in the sentence.
# 5- If that word existed it's gonna try to print it from the if conditional.
# 6- Make spaces betweeen each word with "------"
# 7- At last Print it
while true:
# input the user what does the sys want to type + what words
print("_" * 10)
words = input("What do you want the system to write?: ")
material = input("With what words (it can be 1 word or a sentence): ")
thick = input("Alrite it's made out of {} then how thick can it be - give it a try!: ").format(material)
# Back-end of the program