Skin cancer is one of the most common cancers, and its early detection can have a huge impact on its outcomes. Deep learning, especially convolutional neural networks, perform well in processing massive amounts of data, especially image data in classifying skin cancer. In this paper, convolutional neural networks are mainly used to diagnose and classify 7 types of skin lesions, including melanoma, basal cell carcinoma, melanocytic nevus, actinic keratosis, and intraepithelial carcinoma, benign keratinoid lesions, dermatofibroma, and vascular lesions. First, the characteristics of skin lesion images are analyzed, using image processing technology and sampling technology to preprocess skin lesion images. Then the training parameters of imageNet network are adjusted through the idea of transfer learning on InceptionV3, ResNet50, DenseNet201, and other networks to perform training classification. Furthermore, different convolutional neural network models are built for classification. In order to validate the classification performance of various convolutional neural network models, this paper adopts ISIC 2017 HAM10000 dataset for experiments. The experimental results show that proper preprocessing is necessary when applying CNN for image classification. In classifying the 224*224 skin lesion images, the classical deep convolutional network with DenseNet201 achieved a remarkable performance classification accuracy of 99.12% for training and 86.91% for testing.