Python学习记录

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python学习记录相关的知识,希望对你有一定的参考价值。

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学习记录的主要内容,如果未能解决你的问题,请参考以下文章

Python学习记录day1

Python入门基础学习记录汇率案例学习记录

Python学习记录day6

Python学习记录

Python学习记录-2016-11-29

[Python] Python学习记录