字符串操作,英文词频统计预处理

str="""
440000 广东省
440100   广州市
440103   荔湾区
440104   越秀区
440105   海珠区
440106   天河区
440111   白云区
440112   黄埔区
440113   番禺区
440114   花都区
440115   南沙区
440116   萝岗区
440183   增城区
440184   从化区
440200   韶关市
440203   武江区
440204   浈江区
440205   曲江区
440222   始兴县
440224   仁化县
440229   翁源县
440232   乳源县
440233   新丰县
440281   乐昌市
440282   南雄市
440300   深圳市
440303   罗湖区
440304   福田区
440305   南山区
440306   宝安区
440307   龙岗区
440308   盐田区
440400   珠海市
440402   香洲区
440403   斗门区
440404   金湾区
440500   汕头市
440507   龙湖区
440511   金平区
440512   濠江区
440513   潮阳区
440514   潮南区
440515   澄海区
440523   南澳县
440600   佛山市
440604   禅城区
440605   南海区
440606   顺德区
440607   三水区
440608   高明区
440700   江门市
440703   蓬江区
440704   江海区
440705   新会区
440781   台山市
440783   开平市
440784   鹤山市
440785   恩平市
440800   湛江市
440802   赤坎区
440803   霞山区
440804   坡头区
440811   麻章区
440823   遂溪县
440825   徐闻县
440881   廉江市
440882   雷州市
440883   吴川市
440900   茂名市
440902   茂南区
440903   茂港区
440923   电白区
440981   高州市
440982   化州市
440983   信宜市
441200   肇庆市
441202   端州区
441203   鼎湖区
441223   广宁县
441224   怀集县
441225   封开县
441226   德庆县
441283   高要区
441284   四会市
441300   惠州市
441302   惠城区
441303   惠阳区
441322   博罗县
441323   惠东县
441324   龙门县
441400   梅州市
441402   梅江区
441421   梅县区
441422   大埔县
441423   丰顺县
441424   五华县
441426   平远县
441427   蕉岭县
441481   兴宁市
441500   汕尾市
441502   城区
441521   海丰县
441523   陆河县
441581   陆丰市
441600   河源市
441602   源城区
441621   紫金县
441622   龙川县
441623   连平县
441624   和平县
441625   东源县
441700   阳江市
441702   江城区
441721   阳西县
441723   阳东区
441781   阳春市
441800   清远市
441802   清城区
441821   佛冈县
441823   阳山县
441825   连山县
441826   连南县
441827   清新县
441881   英德市
441882   连州市
441900   东莞市
442000   中山市
445100   潮州市
445102   湘桥区
445103   潮安区
445122   饶平县
445200   揭阳市
445202   榕城区
445221   揭东区
445222   揭西县
445224   惠来县
445281   普宁市
445300   云浮市
445302   云城区
445303   云安区
445321   新兴县
445322   郁南县
445381   罗定市
"""
print("输入你的身份证号:")
id =input()
birthday=id[6:14]
if(int(id[-1])%2==1):
print("性别:男")
else:
print("性别:女")
address=id[0:6]
print("出生日期:"+birthday)
print("出生地方:"+str[str.find(address)+9:str.find(address)+12])

 凯撒密码编码:

str=input()
newStr=""
for s in str:
    ordS=ord(s)
    if ( ordS>=ord('a') and ordS<=ord('z')  or   ordS>=ord('A') and ordS<=ord('Z') ):
        if(  ordS>=ord('x') and ordS<=ord('z')  or   ordS>=ord('X') and ordS<=ord('Z')  ):
            newStr+= chr( ord(s)-23 )
        else:
            newStr+=  chr( ord(s)+3 )
    else:
        newStr+=s;
print(newStr)

网址观察与批量生成:

import webbrowser

for i in range(900,912):
    url='http://news.gzcc.cn/html/2019/xiaoyuanxinwen_0226/10'+ str(i) +'.html'
    webbrowser.open_new_tab(url)
    print(url)

英文词频统计预处理:
file_object = open('aritle.txt','r',encoding='utf8')
file_context = file_object.read()
file_object.close()
print(file_context)
print("大写状态:"+file_context.upper())
print("分割单词状态:")
print(file_context.split(" "))
















猜你喜欢

转载自www.cnblogs.com/manjin666/p/10469672.html
今日推荐