plus basis _day02

DIC1 = {# 
# 'Hebei Province': {
# 'Baoding': [ 'pond area,' 'King show area,' 'the city go'],
# 'Shijiazhuang': [ 'east zone' 'west region']
#},
# 'Shanxi': {
# 'Taiyuan': [ 'Xiaodian', 'Xinghualing'],
# 'Datong': [ 'Heisei area', ' Yungang region '],
#}
#}
# # 4. Add all of the cities in a list, and uses the index print cycle enumerate and city names in this list of cities.
City_list = # []
# '' '
# 1. want to get all the name of the city, it is to get all the values dic1.
Dic1.values # ()
# [{ 'Baoding': [ 'pond area,' 'King show area,' 'the city go'], 'Shijiazhuang': [ 'east zone', 'west region' ]}
# { 'Taiyuan': [ 'Xiaodian', 'Xinghualing'], 'Datong': [ 'Heisei area', 'region Yungang'
]}] # 2. Get to all the values dic1 (dictionary form), the name of the city is that all keys for each dictionary.
# Because of this there are two dictionaries, we use a for loop through.
# '' '
# # Print (List (dic1.values ()))
# # in dic1.values for I ():
City_list.extend # # (i.keys ())
# # # Print (city_list)
# # for NUM, City in the enumerate (city_list):
# # Print (NUM, City)
#
# # 5. Add all of the area to a list.
Area_list # = # []
# # in dic1.values for I ():
# # for J in i.values ():
# # area_list.extend (J)
# # Print (area_list)
#
# Li = [ "vibrato "" old iron nothing wrong "," enough Why children "," who tm buy millet children "]
# # develop sensitive word filtering program prompts the user to type a comment, if the user input contains special characters:
# # sensitive word list li = [ "vibrato" and "old iron nothing wrong", "enough Why children", "who tm buy millet children"]
# # content will be entered by the user in sensitive words replaced with equal length * (vibrato replaces **),
## and added to a list; if the user input is not sensitive words, directly added to the above list.
Comment_list # = # []
# # Comment = INPUT ( 'Enter Comments') .strip () #'

# # If i in comment: # '** toxic enough what children caution'
# # = comment.replace the Comment (i, '*' * len (i)) # '** toxic, please be careful enough what children with '
# # comment_list.append (the comment)
# # Print (comment_list)
#
# # comment_list = []
# # the comment the iNPUT = (' Please enter your comment ') .strip () #' vibrato toxic, please be careful enough what children with '
# # for i in li:
# # = comment.replace the Comment (i,' * '* len (i)) #' ** toxic enough what children caution '
# # comment_list.append (the Comment)
# Print # (comment_list)
# #
# # Comment = 'ABC'
# # Print (comment.replace ( 'Bai', '666'))



Bytes # 

# English angle:
# STR
# S1 = 'Barry'
# # internal code: Unicode
#
# # bytes:
# B = b'barry '
# # internal code: a non-Unicode
# Print (B)


# Chinese angle
# STR
# s1 = 'Zhicungaoyuan'
#
#
# # bytes
# B = B '\ xe5 \ XBF \ X97 \ xe5 \ XAD \ X98 \ xe9 \ xab \ X98 \ xe8 \ XBF \ x9c'
# Print (B)


s1 = ' Bai '
# encode method: encoding, encoded by a non-unicode unicode
# unicode ---> UTF. 8-
B = s1.encode (' UTF-. 8 ')
Print (B)
# unicode ---> GBK
B = S1. encode ( 'GBK')
Print (B)

# decode method: decoding --- non the Unicode> Unicode
# GBK ----> Unicode
B = B '\ XCC \ xab \ XB0 \ XD7'# Gbk bytes of type
s = b.decode ( 'gbk')
print(s) # 太白

# utf-8 ---> unicode
b = b'\xe5\xa4\xaa\xe7\x99\xbd'
print(b.decode('gbk'))
# UnicodeDecodeError、UnicodeEncodeError






Guess you like

Origin www.cnblogs.com/qiaotianzi/p/11946777.html