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))

相關文章
相關標籤/搜索