本文摘自php中文网,作者黄舟,侵删。
这篇文章主要介绍了Python原始字符串与Unicode字符串操作符用法,结合实例形式分析了Python针对原始字符与Unicode字符的操作符用法,需要的朋友可以参考下本文实例讲述了Python原始字符串与Unicode字符串操作符用法。分享给大家供大家参考,具体如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import re
def originalOper():
print "\n"
print r "\n"
try :
testFile = open (r "E:\PythonDemo\CorePythonBook2\output" , "r" )
for line in testFile.readlines():
line = "%r" % line
m = re.search(r "\\[rn]" ,line)
if m is not None :
print line
except Exception,e:
print e
finally :
testFile.close()
def unicodeOper():
print u "abc"
print u "\u1234"
print u "abc\u1234\n"
print ur "Hello\nWorld!"
originalOper()
unicodeOper()
|
运行结果如下:

以上就是关于Python中原始字符串与Unicode字符串操作符的实例的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python搭建网站的基本步骤
Python中的split是什么
Python中import语句是什么 ?有什么作用?
推荐几个适合小白学习Python的免费网站
Python中降序用哪个单词
Python e怎么表示
Python怎么将变量按行写入txt格式里
Python中+=是什么意思
Python实现的质因式分解算法示例
Python换行符是什么?
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 关于Python中原始字符串与Unicode字符串操作符的实例