VS2013中Python学习笔记[基础入门]

前言  html

        在上一节中简单的介绍了在VS2013中如何进行开发Hello World,在VS2013中进行搭建了环境http://www.cnblogs.com/aehyok/p/3986168.html。本节主要来简单的学习一下关于Python的基础。学习

Python基础入门  spa

一、打印一个字符串Hello World.code

print('Hello World')

 

二、打印一个路径htm

print('C:\aehyok\aehyok')

能够发现\a发生了转义。若是不想发生转义,只须要在字符串前添加一个rblog

print(r'C:\aehyok\aehyok')

 

三、字符串拼接和字符串重复次数索引

print('str'+'ing','aehyok'*3)

 

四、字符串两种索引方式,从左到右索引从0开始,从右到左索引从-1开始。开发

word='aehyok'
print(word[0],word[5])
print(word[-1],word[-5])

 

五、对字符串进行切分:用冒号分隔两个索引,形式为变量[头下标:尾下标]。截取的范围是前闭后开的字符串

cat='aehyok'
print(cat[3:])
print(cat[3:6])
print(cat[:-1])
print(cat[-1])

 

六、获取键入字符串,并打印字符串以及字符串长度和类型get

object = input('Enter an ojbect : ')
print("Get anlu integer is",object,type(object),len(object))

相关文章
相关标签/搜索