Python字符串我怎么做 [英] Python strings how do i

查看:103
本文介绍了Python字符串我怎么做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编码我输入的名字=输入('你的名字是什么?')。输出将是你的名字是什么?接下来我希望输出为Hello,无论输入的人是什么。但我不知道如何。

When I was coding i typed name = input('What is your name?'). The output would be What is your name?. Next I want the output to be Hello, whatever the person typed in. But I don't know how.

推荐答案

这是您的解决方案..



here is your solution..

name = input("What is your name?")
print("hello %s" %name)





%s用于字符串..%name是你的变量..

如果你想在运行时输入整数,那么投出你的输入..

%d是整数值..

% f表示浮动值..



%s is for string.. %name is your variable..
if you want integer number at run time then cast your input..
%d is for integer value..
%f for floating value..


您可以在 https://docs.python.org/3.3/tutorial/index.html [ ^ ]。


这篇关于Python字符串我怎么做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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