Python Learning: 01
after a short period of new year days, i found life a little boring. so just do something funny--python. before we begin, what we should know first is that python is a dynamic language, which means the type of data of every varieable
- differences between python2 and python3
as the version i download is python, which i found something wrong with the studying video, i look through some websites.the first point need paying attention to is the change of function 'print', which can be used as output sentense in p2 while can be used as a function in p3.
- unicode in python
if we met " unicodedecodeerror" when coding, add a note line at the first line.
1 # -*- coding: utf-8 -*-
- comparation between list and tuple
list:
1 h=['drunk',1] 2 o=['youth',0] 3 g=[]
tuple:
1 1 h=('drunk',1) 2 2 o=('youth',0) 3 3 g=(('drunk',0),['youth',1])
the greatest difference between them is the whether can be changed. tuple is determined as long as it is defined, while list can be changed by append(), insert(), pop(). but there is a exception that the list in tuple can alse be changed.
上一篇: 小寒节气吃什么养生 十大养生汤抵御寒冷