最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python將字符串轉(zhuǎn)換成數(shù)組的方法

 更新時間:2015年04月29日 09:02:43   作者:重負在身  
這篇文章主要介紹了python將字符串轉(zhuǎn)換成數(shù)組的方法,涉及Python操作字符串與數(shù)組的相關(guān)技巧,非常具有實用價值,需要的朋友可以參考下

python將字符串轉(zhuǎn)換成數(shù)組的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

#-----------------------------------------
#      Name: string_to_array.py
#     Author: Kevin Harris
# Last Modified: 02/13/04
#  Description: This Python script demonstrates 
#         how to modify a string by
#         converting it to an array
#-----------------------------------------
import array
str = 'My name is Kevin'
print( 'str = ' + str )
# We're not allowed to modify strings 
# so we'll need to convert it to a
# character array instead...
charArray    = array.array( 'B', str )
# assignment
charArray[11:16] = array.array( 'B', 'Jason' )
# replacement
str = charArray.tostring()
# assignment back to the string object
print( 'str = ' + str )
input( '\n\nPress Enter to exit...' )

輸出結(jié)果:

str = My name is Kevin
str = My name is Jason
 
Press Enter to exit...

希望本文所述對大家的python程序設(shè)計有所幫助。

相關(guān)文章

最新評論

米泉市| 金乡县| 肃北| 河西区| 乐安县| 日喀则市| 通辽市| 朝阳市| 罗田县| 文昌市| 陆川县| 施秉县| 吴桥县| 金秀| 南溪县| 从化市| 进贤县| 武冈市| 驻马店市| 会昌县| 菏泽市| 杭锦后旗| 临高县| 洛阳市| 东丽区| 涪陵区| 股票| 平遥县| 日照市| 通山县| 兴隆县| 白山市| 白城市| 新兴县| 鹤壁市| 尖扎县| 宁武县| 尼玛县| 株洲市| 丘北县| 安远县|