在搭建整个web项目之前,需要学习一下Python语言,Python语言入门比较简单,这里简单介绍一下Python语言一些基础知识点(主要以代码+注释介绍)。
# -*- encoding=UTF-8 -*- import requests import random from bs4 import BeautifulSoup
#python字符串介绍
def string_demo():
str='hello world' #首字母大写 print str.capitalize()
#字母替换
print str.replace("world",'liu',10)#判断字符串的开头结尾
print str.startswith("he")
#判断字符串的开头结尾
print len(str)
#字母拼接为字符串
print '_'.join(['a','b'])