1.”“” python中三个引号连续使用,是长字符串输入的开端,例子是这样。
print """
Alright, so you said %r about liking me.
You live in %r. Not sure where that is.
And you have a %r computer. Nice.
""" % (likes, lives, computer).
2.转义字符表
转义字符 实现功能
\ Backslash ()
’ Single-quote (’)
" Double-quote (")
\a ASCII bell (BEL)
\b ASCII backspace (BS)
\f ASCII formfeed (FF)
\n ASCII linefeed (LF)
\N{name} Character named name in the Unicode database (Unicode only)
\r ASCII Carriage Return (CR)
\t ASCII Horizontal Tab (TAB)
\uxxxx Character with 16-bit hex value xxxx (Unicode only)
\Uxxxxxxxx Character with 32-bit hex value xxxxxxxx (Unicode only)
\v ASCII vertical tab (VT)
\ooo Character with octal value ooo
\xhh Character with hex value hh
- raw_input 和argv
值得注意的是
raw_input() 的里面可以添加提示,比如说 user_name(“what is the name of your pc?:”)二而argv是不可以的。
其次,argv在命令行运行脚本的时候 地址+文件名+argv里需要获取的变量才可以运行。否则会提示
ValueError: need more than 1 value to unpack
4.pydoc 并不能运行成功。而且不知道原因是什么。
5.
#this one is like your scripts with argv
def print_two(*args):
arg1,arg2 = args
print "arg1,%r,arg2: %r" % (arg1,arg2)
#ok, that *args is actually pointless,we can just do this
def print_two_again(arg1,arg2) :
print "arg1: %r,arg2: %r" % (arg1,arg2)
#this just take one argument
def print_one(arg1):
print"arg1:%r" % arg1
#this just take no arguments
def print_none():
print"I 'v got nothing here."
print_none()
print_one(123)
print_two(123,123456)
print_two("zed","shaw")
print_two_again("Zed","Shaw")
#函数注意事项
#1.函数定义是以def 开始的
#2.函数名称是以字符和下划线_组成的
#3.函数名称是要跟着括号的。
#4.括号里需要跟着参数,多个参数之间要用逗号隔开
#5.参数名称不能使用重复的 make sure that each argument is unique。
#6.变量名后面