python学习笔记(一)

 
>>> print('The quick brown fox', 'jumps over', 'the lazy dog')
The quick brown fox jumps over the lazy dog

print()会依次打印每个字符串,遇到逗号“,”会输出一个空格,因此,输出的字符串是这样拼起来的:

print-explain

name = input('please enter your name: ')
print('hello,', name)
 

序一运行,会首先打印出please enter your name:,这样,用户就可以根据提示,输入名字后,得到hello, xxx的输出:

最后,请务必注意,Python程序是大小写敏感的,如果写错了大小写,程序会报错。

如果字符串内部有很多换行,用 写在一行里不好阅读,为了简化,Python允许用'''...'''的格式表示多行内容

>>> print('''line1
... line2
... line3''')
line1
line2
line3
空值

空值是Python里一个特殊的值,用None表示。None不能理解为0,因为0是有意义的,而None是一个特殊的空值。

# -*- coding: utf-8 -*-
> 'Hi, %s, you have $%d.' % ('Michael', 1000000)
如果你不太确定应该用什么,%s永远起作用,它会把任何数据类型转换为字符串:
原文地址:https://www.cnblogs.com/liguangao/p/5178464.html