Digital Type
1. Role: represents a number
2 is defined way
3. Use
You can perform mathematical operations
String
2. The role: representing a name / gender
3. Define the way
String up single quotes
Three characters in quotation marks can be wrapped, and the characters in single or double quotation marks does not work
4. Method
startswith: to. . . . Start
endswith: to. . . . End
Index Value
Index sliced
List
effect
He represents hobby
Defined way
With [] storage, a plurality of elements separated by a comma (which may be of any data type)
For a list of deposit is not an end, whichever is the goal
4. Method
Index values
Sliced
dictionary
Role dictionary
A plurality of values used to access, in accordance with key: value way, when the key value can be taken, having a key role for the descriptive value.
3. Use a dictionary
Press the key value by modifying key values del delete value
Construction of a word cloud
Import wordcloud
Import jiebafrom ImageIO
from imread Import matplotlib
TXT = '' 'Spring tide with sea level, sea moon tide students. Yan Yan with wave thousands of miles, where the Spring River next month free! The river reverberates around Fangdian, on photo flower forest are like sleet; in air stream feel fly cream, white sand Ting invisible. Color without Qian Chen Tianyi Jiang, March solitary round shining air. River, who has shown signs of months? Jiang month shine on people? Life has infinite generations, Jiang month year after year look similar. I do not know who to be on a river, the whole Yangtze send water. Baiyun go a long, very unhappy on Seifu Pu. Whose Tonight boat child? Where Acacia moon House? Upstairs month wandering poor, who should light the stage makeup. Jade door curtain not volume, pound anvil on clothes brush also come. Not hear each case, willing to monthly flow Zhao Jun. Geese fly long light is not the degree, latent jump ichthyosaur water written. Tan idle dream last night falling, the poor are not yet spring a half home. River water spring to Yujin, Jiang Tan sangrakwol complex West Ramp. Diagonal Mar possession of heavy sea fog, Tateishi Xiaoxiang unlimited way. I do not know take a few months people go, love Mitsue sangrakwol shake the tree. '' ' # Word cloud document "Moonlit Night"
txt_list = jieba. LCUT ( TXT) # segmentation and composition of space-separated list of
TXT = ' '. The Join ( txt_list) # list into a string
MK = imread ( ' Dance .png ') # Import pictures
w = wordcloud. Wordcloud ( font_path = "C: \ Windows \ STLITI", width = 1000, height = 1000, font_step = 1, background_color = "Pink", mask = MK) # configuration object parameter w. The Generate ( TXT) w. to_file ( "pywordcloud.png") # output Image