首页 > 编程语言 > 详细

Python学习记录(一)

时间:2016-03-02 17:45:53      阅读:178      评论:0      收藏:0      [点我收藏+]

1 运行python脚本(方法一)
python hello.py

运行python脚本(方法二)
在脚本第一行加上 #!/usr/bin/env python
修改脚本权限: chmod a+x hello.py
执行 ./hello.py

2 注释格式
# : #右边的代码会被忽略

3 字符串
1) 使用单引号和双引号没有区别
“hello, world” == ‘hello.world‘ ==> ‘hello,world‘

2) 数值转化为字符串
"hello" + str(123)
"hello" + repr(123)
‘123 ?? 反引号??

3) input 和 raw_input
input("what is your name?") # 输入 "yilia" 必须带有""
raw_input("what is your name?") # 输入 yilia即可 无需带有""

4 原始字符串和unicode字符串
原始字符串以 r 开头: print r‘C:\program\foo\bar‘ ‘\\‘
unicode字符串以u开头: u‘hello, world!‘

 

Python学习记录(一)

原文:http://www.cnblogs.com/songshu-yilia/p/5235623.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!