Python打印初学者
我刚从Python开始。我的老师给了我一个作业,我陷入了一个项目,当有人输入输入命令输入(“什么是你的名字”) i Don时,我必须使角色数量出现。 ``认为我已经被教了这个,而Google试图寻找命令时给我一个困难。这可能是大多数孩子玩的孩子,但是有人可以给我一个提示/提示吗?
I just started with python. My teacher gave me an assignment and I'm stuck on a project where I have to make the numbers of characters appear when someone enters their name for input command input("what is your name") I don't think I have been taught this and google is giving me a hard time when trying to look for the command. This might be Childs play to most but can anyone throw me a tip/hint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Python 打印变量的长度非常容易,因为您可以对字符串执行许多内置函数!在这种情况下,您将使用
len()
。阅读Python 中其他有用的字符串方法,以便在课堂上取得领先!第一个打印语句使用名为 字符串连接 的内容来使用变量创建可读的句子。第二个使用 f strings 来在您的字符串更容易!
Printing the length of a variable is very easy with Python due to the many built-in functions you can perform on strings! In this case, you would use use
len()
. Read about other helpful string methods in python too in order to get a head start on your class!The first print statement uses something called string concatenation to create a readable sentence using variables. The second uses f strings to make using variables in your strings even easier!
使用
print(len(myvariable))
应输出字符串具有的字符数。您应该熟悉Python方法。这里有一些资源:
https://docs.python.org/3/library/library/fimpunctions.htmlunctions.html
https://www.w3schools.com/python/python/python/ref_func_len.len.len.len.len.len.len.len.asp
using
print(len(myVariable))
should output the number of characteres that the string has. You should familiarize yourself with python methods.Here are some resources:
https://docs.python.org/3/library/functions.html
https://www.w3schools.com/python/ref_func_len.asp