python Lesson

python2 to python3 # 

# python2
#Print () Print 'ABC'
#range xrange () generator
#raw_input ()

# to python3
# Print ( 'ABC')
# Range ()
# INPUT ()
# == assigned values for equality comparison is comparison, to compare the memory address, ID (content)
# in Li1 = [l, 2,3]
# LI2 in Li1 =
# = LI2 LI3
# Print (ID (in Li1), ID (LI2), ID (LI3))
# digital , small data string pool
# -5--256 range of numbers
# string: 1, can not have special
# 2, s * 20 is the same address, s * 21 are two subsequent addresses
# = I1. 6
# I2 =. 6
# Print (ID (I1), ID (I2))
# I1 = 300
# I2 = 300
# Print (ID (I1), ID (2))
A1 = 'aaaaaaaaaaaaaaaaaaaaaaaaaa'
A2 = 'aaaaaaaaaaaaaaaaaaaaaaaaaa'
Print (A1 IS A2)

# remaining tuple SET dict List
# L1 = [. 1,]
L2 = # [. 1,]
# Print (L1 L2 IS)

#ascii
# A: 00000000. 8 bits of a byte
#unicode A: 00000000 00000000 00000000 00000000 32 Bit 4 bytes
# of: 00000000 00000000 00000000 00000000 4 32 bytes,
# UTF-a. 8: 0010 0000 00000000. 8 bits of a byte
# of: 0,000,001,000,000,110 000 000 001 24 3 bytes
#gbk a: 00000110 8 bits of a byte
# of: 0,000,000,010,000,001,016 words bit 2 section
# 1, between the various binary coding, can not recognize each other, will be garbled
# 2, file storage, transmission, is not unicode (only utf-8 utf-16 gbk, gb2312, asciid etc.)
# Py3:
#str in memory is stored in unicode
#bytes type
# for English:
#str: expressions: S = b'alex '
#
# encoding: 000 101 010
# UTF -. 8
# GBK. . . .
#
# For the Chinese:
# str: forms: s = 'China'
Encoding #: 010101010
# Unicode
# bytes: expressions: S = b'x \ E91 \ E91 \ E01 \ E21 \ E31 \ E32 '
# encoding: 000.10101 million
# UTF -. 8
# GBK. . . .
# Buyers and sellers of goods money
Li = [
{ 'name': 'apple', '. Price': 10},
{ 'name': 'banana', '. Price': 20 is},
{ 'name': 'watermelon' '. price': 30},
]
# the goods on the shelves
print ( 'Welcome to Kai Lai fruit shop')
money = the INPUT ( 'Show me your money')
IF money.isdigit () and int (money )> 0:
for I, K in the enumerate (Li):
. Print ( 'number {} trade {}, the price {}' the format (I, K [ 'name'], K [ '. price']))
the Choose = input ( 'Please enter the number of goods you buy')
IF choose.isdigit () and int (the Choose) <len (li):


int IF (Money)> Li [int (the Choose)] [ '. price'] * int (NUM):
Money = int (Money) -Li [int (the Choose)] [ '. price'] * int (NUM)
IF Li [int (the Choose)] [ 'name'] in shopping_car:
shopping_car [Li [int (the Choose)] [ 'name']] = shopping_car [Li [int (the Choose)] [ 'name']] + int (NUM)

the else:
Print ( "beast, go back for money with your wife!")


the else:
Print ( 'say the number is, you silly ah!')

Guess you like

Origin www.cnblogs.com/huangjianfeng/p/11220195.html