码迷,mamicode.com
首页 > 编程语言 > 详细

《Python基础教程》第1章读书笔记

时间:2017-04-06 19:59:45      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:输出   input   blog   --   python   over   eval   file   div   

# -*- coding:utf-8 -*-

x = "hello "
y = "world"
print x+y
print "hello "+y

#repr() eval()
x = repr("hello")
val = eval(x)
print x
print val
print "hello"
print str("hello world!")

y = [1,2,3,4]
print repr(y)

print str(10000L)

print repr(1000L)

temp = 42
print "The temperature is "+repr(temp)

#raw_input()
name = raw_input("what is your name?")
print "hello, " + name + "!"

#长字符串、原始字符串和Unicode
#长字符串
print ‘‘‘This is a very long string.
It continues here.
And it‘s not over yet.
"Hello world!"
Still here.‘‘‘

#反斜线使换行符转义
print "hello, world!"

print 1+2+3

print "hello world"

#换行符\n
print Hello \nworld!

#打印反斜线 
print C:\\nowhere

#打印路径---打印原始字符串
print "C:\\Program Files\\fnord\\foo\\bar\\baz\\frozz\\bozz"
print rC:\nowhere
print rC:\Program Files\fnord\foo\bar\baz\frozz\bozz

print rLet\‘s go!
print Let\‘s go!

#原始字符串最后一个字符不能是反斜线
#print r"This is illegal\"
#要想在输出字符串末尾加反斜线,可以再接一个单独的字符串来处理
print r"This is illegal"‘\\

#Unicode字符串
print u
print uHello world!

 

《Python基础教程》第1章读书笔记

标签:输出   input   blog   --   python   over   eval   file   div   

原文地址:http://www.cnblogs.com/HITSZ/p/6674880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!