【Python】-007-语句表达式-赋值/输入输出
2017-07-16 本文已影响6人
9756a8680596
多重赋值
a, b = 1, 2
a, b = 'bj', 'sh'
a = b = 'bj'
a, b = (1, 2)
a, b = [1, 2]
输入/输出
-
输入
name = raw_input('Please input your name: ') //不做转换,当做字符串接受
print 'Hello, ' + name
type(name)result = input('Please calculate 2*10 ?') //将执行后对结果返回变量 print '2*10 is ' + result type(result)
-
输出
- Python 3.x
- 函数
print([object, ..., ]*, sep=' ', end='\n', file=sys.stdout)
- 函数
- Python 2.x
- 语句,
print a, b
print >>file, a, b
print '{0} like {1} '.format('we', 'python')
print '{a} like {b} '.format(a='we', b='python')
- 语句,
- Python 3.x