python基础篇:python for循环
For循环是迭代对象元素的常用方法(在第一个示例中,列表),具有可迭代方法的任何对象都可以在for循环中使用。
print( )函数、input( )函数
用 Python 来打印 ‘Hello, world’ 你会惊奇地发现Python是如此的简洁与优雅。
In [ ]
# 打印Hello, world
print('Hello, world')
Hello, world
In [ ]
# input()函数:接受一个标准输入数据,返回为string类型
name = input("请输入你的昵称:")
print("你好,"+ name + "!")
请输入你的昵称:你好,行远见大!
字符串:str( )、整型数:int( )、浮点数:float( )
- 字符串:str( )、整型数:int( )、浮点数:float( ) 用法
- 类型转换
In [ ]
# str()的作用:把一个数或任何其他类型转换成字符串
name = input("请输入你的昵称:")
# 其实在此处有name = str(name)的一个过程
print("你好,"+ name + "!")
请输入你的昵称:你好,行远见大!
In [ ]
# 此处
还没有评论,来说两句吧...